Phalcon How to do SELECT not in with SUB QUERY in query manager?

like to know how do i use select not in as a subquery in phalcon

for example i know i can use following to do the notIn with a array values.

return User::query() ->where(" gender!=:gender: ", array('gender' => $gender)) ->andWhere(" verify=1 ") ->notInWhere('userid', "SELECT userid FROM userbannned WHERE userid=:userid:" ) ->order(" lastvisit DESC ") ->limit($limit) ->execute();

Problem is

"SELECT userid FROM userbannned WHERE userid=:userid:"

how do i do this subquery with model query manager ?

ANY ideas ? or workarounds ?

Just like in mysql.



4.3k

Just like in mysql.

What you mean by this ? SELECT Subquery dont work in models



4.3k

hasOne, hasMany , phql https://docs.phalconphp.com/en/latest/reference/phql.html

Can you exaplain in details how you can do this ? becaue i want soemthng like below done

User::query() ->andWhere(" gender!=:gender: ", array('gender' => $gender)) ->andWhere(" verified=1 ") ->inWhere('mode', ['active','pending']) ->notInWhere('userid',"(SELECT userfrom AS userid FROM XYZ\Models\UsersBlock WHERE userto=:userid:) UNION (SELECT userto AS userid FROM XYZ\Models\UsersBlock WHERE userfrom=:userid:)") ->bind('userid',$this->user->userid) ->order(" lastvisit DESC ") ->limit($limit)