Answer the question
In order to leave comments, you need to log in
How to do double select WHERE with DAO in Yii2?
There is a controller
public function actionIndex()
{
$accountident = Yii::$app->user->identity->account;
$users = $db->createCommand("SELECT * FROM transactions WHERE sender='$accountident' AND payee='$accountident'")->queryAll();
$dataProvider = new ArrayDataProvider([
'allModels' => $users,
]);
return $this->render('index', [
'dataProvider' => $dataProvider,
]);
}
Answer the question
In order to leave comments, you need to log in
This means that there is no entry in the transactions table that you want to find
. In general, it is better to write queries in Yii in this form:
$users = $db->createCommand()
->select('*')
->from('transactions')
->where ('sender=:sender', array('sender' => $accountident))
->andWhere('payee=:payee', array('payee' =>$accountident))
->queryAll();
It will be safer.)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question