Yii2 Get Database with Array as an 'IN' -


i want show datas in view, there's error

here's code

controller :

first, want put number in $row

$row = table1::find('number')->where(['username' => yii::$app->user->identity->username])->asarray(); 

then, want find datas in table2 $row in

$show = table2::find()->where(['id_user' => $row])->all(); 

and, render view

return $this->render('view', ['show' => $show]); 

view :

i use foreach show $show

<?php   foreach($show $s): ?>     <?= $s->data ?>  <?php   endforeach; ?> 

but shows error :

sqlstate[21000]: cardinality violation: 1241 operand should contain 1 column(s) 

anyone can me?

thanks

the error you're getting caused by code bit: table1::find('number')
argument pass find() needs condition (expression, string or array format) where()

i'ts not clear question doing particular query,
perhaps need this:

table1::find()->select(['number'])->where( ... ); 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -