如何在 yii 中编写此查询并在不使用 foreach 循环的情况下打印它?
How to write this query in yii and print it without using foreach loop?
我已经在 sql 中编写了这个查询并且它工作正常,我得到了我想要的确切结果,但是当我在 Yii 中编写这个查询时,如果我不使用 foreach 循环我收到此错误 array to string conversion
。
在 sql
中查询
SELECT description FROM `comment_business` where review_business_id=72;
在 Yii 中查询
$results=Yii::app()->db->CreateCommand()
->select('description')
->from('comment_business b')
->where('b.review_business_id='.$ba->id)
->queryRow();
echo $results;
我在 sql 中知道,我得到了描述,但是在这里,我如何在不使用 foreach 循环的情况下实现我的结果?
我有
如果你只得到一行,试试
echo $result['description'];
如果你得到不止一行你需要索引
echo $result[0]['description'];
我已经在 sql 中编写了这个查询并且它工作正常,我得到了我想要的确切结果,但是当我在 Yii 中编写这个查询时,如果我不使用 foreach 循环我收到此错误 array to string conversion
。
在 sql
SELECT description FROM `comment_business` where review_business_id=72;
在 Yii 中查询
$results=Yii::app()->db->CreateCommand()
->select('description')
->from('comment_business b')
->where('b.review_business_id='.$ba->id)
->queryRow();
echo $results;
我在 sql 中知道,我得到了描述,但是在这里,我如何在不使用 foreach 循环的情况下实现我的结果?
我有
如果你只得到一行,试试
echo $result['description'];
如果你得到不止一行你需要索引
echo $result[0]['description'];