I have Question
and Answer
models. The Question hasMany Answers. Following commands run in the php artisan tinker
mode invoke a database query for no apparent reason:
$q = new Question;
$q->answers[] = new Answer; // invokes the below query
// the executed query
select * from `answers` where `answers`.`question_id` is null and `answers`.`question_id` is not null
As you see, there is no need for database call whatsoever. How can I prevent it?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1YZTgyN
via IFTTT
Aucun commentaire:
Enregistrer un commentaire