We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to add multiple conditions in leftjoin in Phalcon\Mvc\Model\Query\Builder

How to add multiple conditions in leftjoin in Phalcon\Mvc\Model\Query\Builder .... for example if i want to add an extra condition in the below code like Robots.name="name"....How can i do this?

                    $builder->leftJoin('Robots', 'r.id = RobotsParts.robots_id', 'r');
edited Mar '17
 $builder->leftJoin('Robots', "r.id = RobotsParts.robots_id AND Robots.name = 'name'", 'r');

But this should be on where part i think.

But this should be on where part i think.

@Wojciech it depends what you want to achieve. If you want all rows with empty fields you can add the conditions from the joined table in the leftJoin() method. If you want to skip partial results you can add them as extra where() methods.

you could just add one more leftjoin