I have a line like this:
$line= Yii::app()->db->createCommand()->select('line_no')->from('tblvehicleimage') ->where('serial_no=:serial_no', array(':serial_no'=>$model->serial_no)) ->queryScalar();
how to put all the $line data in an array? Is there any way i can use 'mysql_fetch_array'?
queryScalar
means only one record will be retrieved.You want to use
serial_no IN (1, 2, 3)
for example, andqueryAll()
instead ofqueryScalar()
.Once the query is successful,
$line
will contain an array, you then simply have to loop through the results:Since you want to select only line_no from the table, you can also use
queryColumn()
If you want one-dimensional array like
as your result then you can use queryColumn()
But if you want
as your answer then you can use queryAll().
Choice is yours :)