A
A
Alexander2016-02-18 22:09:48
Yii
Alexander, 2016-02-18 22:09:48

How to use AS in findBySql?

$sql = 'SELECT image_owner AS img FROM owner';
        echo '<pre>';
        $model = Owner::findBySql($sql)->all();
        print_r($model);

I do something like this but output an empty array. And so the image_owner table is not empty.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2016-02-19
@dmitrydeco

$sql = 'SELECT image_owner AS img FROM owner';
echo '<pre>';
$model = Owner::model()->findBySql($sql);
print_r($model);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question