H
H
hrusska2014-04-17 16:56:33
MySQL
hrusska, 2014-04-17 16:56:33

Why, under the specified condition in connection with the HAS_MANY type, if there is no data in the associated table, does it not find the main record?

There is an AR Publications class that is related to the Commentaries class.
The commentaries table stores comments related to many modules, not just Publications, so a condition must be specified when fetching.
When I try to select a post for which there are no comments, I get nothing . :(
Communication description

...
'commentariesToDetail' => [
  self::HAS_MANY,
  'Commentaries',
  array('parent_id' => 'id'),
  'condition' => 'commentariesToDetail.module = :module',
  'params' => array(':module' => Commentaries::MODULE_PUBLICATIONS),
]
...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Cage, 2014-04-18
@Cage

Because you have specified a selection condition
accordingly you tried to select all Publications posts that have comments with the 'module' field value of Commentaries::MODULE_PUBLICATIONS
remove the condition or replace this line with the following :
'on' => 'commentariesToDetail.module = :module',

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question