0

I 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 ?

mahen3d
  • 7,047
  • 13
  • 51
  • 103
  • Look [here](http://stackoverflow.com/questions/33772911/phalcon-how-do-i-do-a-select-in-subquery-with-phalcon-models/33777183#33777183) and [here](http://stackoverflow.com/questions/33446366/phql-where-xxx-in-can-get-only-1-data/33823669#33823669). – yergo Dec 11 '15 at 12:12

1 Answers1

0

What exactly is your problem ?

Just do the same:

$this->modelsManager->createBuilder()
    ->from(['User'=>'User Namespace'])
    ->where("gender != :gender:,array('gender'=>$gender))
    ->andWhere("verify=1")
    ->notInWhere('user_id', "SELECT user_id FROM user_banned WHERE user_id = :user_id:")
    ->order("last_visit DESC")
    ->limit($limit)
    ->getQuery()
    ->execute();

Thats it.

Juri
  • 1,369
  • 10
  • 16
  • i get a error Phalcon\Mvc\Model\Criteria::notInWhere() must be of the type array, string given, called in – mahen3d Dec 14 '15 at 01:35