2

I have written this query in sql and it is working fine, I am getting the exact result which I wanted, but when I write this query in Yii, and if I do not use foreach loop I get this error array to string conversion. Query in sql

SELECT description FROM `comment_business` where review_business_id=72;

Query in Yii

 $results=Yii::app()->db->CreateCommand()  
                                ->select('description')
                                ->from('comment_business b')
                               ->where('b.review_business_id='.$ba->id)
                                ->queryRow();
     echo $results;

I know in sql, I get the description, but here, how can I achieve my results, without using foreach loop ?

I have

1 Answer 1

1

if you get an only row try

echo $result['description'];

if you get more than a row you need index

 echo $result[0]['description'];
Sign up to request clarification or add additional context in comments.

1 Comment

Oh how stupid I am, it was so simple, Thanks Scais sir.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.