php - Updating an Object in Symfony Doctrine -
i stuck on project , want help. have 3 tables in database (reviews, criteria , criteriascope), showcase code below. in reviews table have 4 fields, id, review, score , total, score , total can null. score array, words saved if word in reviews matched word in criteria table , total count of positive or negative words in score field.
in index view show reviews(without score , total) , have button , when pressed want
1) update database find matched words , set them in score field and,
2) update total field respectively words score field.
here code:
reviews entity
class reviews /** * @var int * @orm\column(name="id", type="integer") * @orm\id * @orm\generatedvalue(strategy="auto") */ private $id; /** * @var string * * @orm\column(name="review", type="string", length=500) */ private $review; /** * @var array * * @orm\column(name="score", type="array", nullable=true) */ private $score; /** * @var int * * @orm\column(name="total", type="integer", nullable=true) */ private $total;
and getters/setters..
criteria entity
** * @var int * * @orm\column(name="id", type="integer") * @orm\id * @orm\generatedvalue(strategy="auto") */ private $id; /** * @var string * * @orm\column(name="topic", type="string", length=30) */ private $topic; /** * @orm\onetomany(targetentity="criteriascope", mappedby="criteria", cascade={"persist"}) */ private $criteriascope;
and getters/setters
criteriascope entity
/** * @var int * * @orm\column(name="id", type="integer") * @orm\id * @orm\generatedvalue(strategy="auto") */ private $id; /** * @var string * @orm\column(name="positives", type="string", length=50) */ private $positives; /** * @var string * * @orm\column(name="negatives", type="string", length=50) */ private $negatives; /** * @orm\manytoone(targetentity="criteria", inversedby="criteriascope", cascade={"persist"}) * @orm\joincolumn(name="criteria_id", referencedcolumnname="id") */ private $criteria;
plus getters/setters
so want is, in analyzedaction, compare each review each criteriascope.positive , criteriascope.negative, , update score , total field in reviews database.
thank in advance :)
p.s: using symfony 2.8
Comments
Post a Comment