I have this test method, where I am using \yii\db\Query().
public static function test()
{
return (new \yii\db\Query())
->select('post_id')
->from('comment')
->where(['in', 'id', [9, 94]])
->all();
}
To display results I have to do this:
<?php foreach (Model::test() as $test): ?>
<?= $test['post_id'] . "<br>" ?>
<?php endforeach ?>
But I would like to have array of objects to work with like this:
<?php foreach (Model::test() as $test): ?>
<?= $test->post_id . "<br>" ?>
<?php endforeach ?>
Is this possible somehow ? Also Is it possible with DAO too ?
I ma using \yii\db\Query() and DAO because I will have to write some really complex sql queries and do not know how to do them with AR. Thanks