我想从user_request_wallet
表中得到数据,其中lead_developer =?和answer_tocall是?或者是?我想加入mainRequest
表。yii2 right sql命令来执行我的查询
应该如何命令???
我试过2的方式,但没有成功
//$model = UserRequestWallet::find()->Where(['and',['lead_developer' => $getUser]])
//->andWhere(['and',['answer_tocall' => 'accepted']])
//->andWhere(['or',['answer_tocall' => 'putonhold']])
//->joinWith('mainRequest');
$model = (new \yii\db\Query())
->select('*')
->from('user_request_wallet')
->andwhere(['lead_developer'=> $getUser])->andWhere(['answer_tocall' => 'accepted'])
->orWhere(['answer_tocall'=>'putonhold'])->leftJoin('mainRequest');
头说
Exception (Database Exception) 'yii\db\Exception' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE ((`lead_developer`=7) AND (`answer_tocall`='accepted')) OR (`answer_tocall' at line 1
正在执行的SQL是:
SELECT COUNT(*) FROM `user_request_wallet` LEFT JOIN `mainRequest` WHERE ((`lead_developer`=7) AND (`answer_tocall`='accepted')) OR (`answer_tocall`='putonhold')
'$ getUser'的值是多少?我认为它不是一个单一的价值。它的数组可能是 –
它是一个数字它的7 – moh
好吧,那么我认为不同类型的quotes'可能是一个问题。你可以尝试不用引号列或表名称? –