1

I want to select only year from records ane make from this data assoc array

$wynik = $model_post::model() -> findAllBySql('SELECT DISTINCT YEAR(create_time) as rok FROM tbl_post');
for($i;$i<count($wynik);$i++)
{
    $rok[$wynik[$i]->rok]=$wynik[$i]->rok; 
}

but I got the exception

_Property "Post.rok" is not defined._

How can I make it correct?

1 Answer 1

2

If I remember correctly this should work in Yii1 as well: define a variable public $rok; in your model_post class, and it will automatically be populated when you use that query.

Sign up to request clarification or add additional context in comments.

Comments

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.