I've not look deep into the AR component but still wanna ask if anyone know how to fetch row from AR query in the same way of fetching from DataReader.
For example:
$articles = Article::model()->findAll(); //I have an array of Article object
If I need to perform some modification to each object then I have to make a loop and it slows down performance. I am thinking about
$resource = Article::model()->findAll(param1, param2,....,return_raw_resource)
while(($article = $resource->read()) != false){
//modify $article's attributes
//add to an array
}
Thanks
Page 1 of 1
Fetching row from AR query
#1
Posted 31 December 2009 - 12:57 AM
FlexicaCMS modular architecture, reusable widgets, customizable widgets on front-pages, native multi-lingual content support, RBAC with dynamic user roles.
Created by Flexica team, Gia Han Online Solutions
Created by Flexica team, Gia Han Online Solutions
#2
Posted 31 December 2009 - 07:59 AM
I don't think that can be done. CActiveRecord does have some methods for bulk updating though, and there's also afterFind(). Maybe that'll help?
#3
Posted 31 December 2009 - 11:10 PM
Sander, on 31 December 2009 - 07:59 AM, said:
I don't think that can be done. CActiveRecord does have some methods for bulk updating though, and there's also afterFind(). Maybe that'll help?
Thank Sander.
For my sample code afterFind() helps partialy. In fact, as I will return the result articles to an ajax request, what I need is just the $article->attributes array. Digging Yii code
FlexicaCMS modular architecture, reusable widgets, customizable widgets on front-pages, native multi-lingual content support, RBAC with dynamic user roles.
Created by Flexica team, Gia Han Online Solutions
Created by Flexica team, Gia Han Online Solutions
Share this topic:
Page 1 of 1

Help












