phalcon.eager-loading icon indicating copy to clipboard operation
phalcon.eager-loading copied to clipboard

Phalcon >= 2.0.4 conditions on relationships

Open Surt opened this issue 9 years ago • 2 comments

Since Phalcon 2.0.4 it's possible to write conditions on relationships 2.0.4 changes, under Relationships with conditionals

But it seems to fail when using the Loader

$users = Loader::fromResultset($users, ['favouriteImage']);

been favouriteImage a relationship with conditional it does not ask for the condition, only the relationship. Of course, actually the loader allows to override the relationship with the Querybuilder, but I will like to avoid this since my domain logic and data providers become a mess.

Again, thank you very much @stibiumz for your library, it does the phalcon orm more useful.

Surt avatar Oct 20 '15 15:10 Surt

I can confirm, conditions do not work. The following is how it should work:

$this->hasMany('id', 'RobotsParts', 'robots_id', [
    'params' => ['conditions' => 'something = 1']
]);

josefguenther avatar Feb 25 '16 22:02 josefguenther

Grate library @stibiumz . Same issue. I think before the line blow https://github.com/stibiumz/phalcon.eager-loading/blob/b3028a9ac828a2945bf9859a72b2a7667acd65a9/src/EagerLoading/EagerLoad.php#L133 you need to process the params part of relation options

erisrayanesh avatar Mar 04 '18 06:03 erisrayanesh