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('user_id', "SELECT user_id FROM user_bannned WHERE user_id=:user_id:" ) ->order(" last_visit DESC ") ->limit($limit) ->execute();

Problem is

"SELECT user_id FROM user_bannned WHERE user_id=:user_id:"

how do i do this subquery with model query manager ?

ANY ideas ? or workarounds ?

Just like in mysql.



8.2k

Just like in mysql.

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



8.2k

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('user_id',"(SELECT user_from AS user_id FROM XYZ\Models\UsersBlock WHERE user_to=:user_id:) UNION (SELECT user_to AS user_id FROM XYZ\Models\UsersBlock WHERE user_from=:user_id:)") ->bind('user_id',$this->user->user_id) ->order(" last_visit DESC ") ->limit($limit)