mysql - What will be the best practice which I should use? -


i newbie in symfony2. have table in exists 5 columns: answer_a, answer_b, answer_c, answer_d , correct_answer.

answers a-d contain text answer in abcd quiz. in correct_answer have "a", "b", "c" or "d" string. how can in best possible way show user correct text answers? should add entity new "text_correctanswer" field? or should create in controller new array correct text answers?

you need onetomany relationships

documentation examples

use doctrine\common\collections\arraycollection;  /** @entity */ class quiz {     protected $id;      /**      * @onetomany(targetentity="answer", mappedby="quiz")      */     protected $answers;      public function __construct()     {         $this->answers = new arraycollection;     } }  /** @entity */ class answer {     protected $id;     protected $iscorrect;      /**      * @manytoone(targetentity="quiz", inversedby="answers")      * @joincolumn(name="quiz_id", referencedcolumnname="id")      */     protected $quiz; } 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -