We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

phql, where statement in joined table

hi all, how can i make where statement in phql query builder for field in joined table my phalcon configuration is using module and namespace

sample 2 tabel

  • tabel user -- field user_id -- fied user -- field role_id

  • tabel role -- field role_id -- field role

i want select from user join with role where role="operator"

tanks before

edited Oct '14

i make it work

        $builder = $this->modelsManager->createBuilder();
        $builder->join('Sistem\Model\CrPeran', 'p.peran_id = u.peran_id','p');
        $builder->where('p.peran = :slopok: or p.peran = :wader:',array('slopok'=>'Operator','wader'=>'Administrator'));
        $builder->andWhere('user_aktif = :x:', array('x' => 0));

        $user = $builder->getQuery()->execute();
        foreach ($user as $x) {
            echo $x->user." ".$x->CrPeran->peran."<br>";