Mr. Carl Thu Jan 26 15:21:58 -0500 2012
Short answer I don't know because I'm also new however I did find something that may help you.
See http://www.yiiframework.com/forum/index.php?/topic/10233-activerecord-to-json/page__p__50334#entry50334
Code snippet from the url:
1 $models=Bla::model()->findAll();
2 $data=array_map
3 (
4 create_function('$m','return $m->getAttributes(array(\'id\',\'name\'));'),$models
5 );
6 echo json_encode($data);
Yoan B Sat Jan 28 10:25:05 -0500 2012
@MrCarl it's PHP 5.3, you shouldn't need create_function anymore.
http://www.phpactiverecord.org/projects/main/wiki/Utilities#serialization
(1-2/2)
Subject: Any progress on an easier json encoding?
Hi,
Just trying out php.activerecord and first impressions are great.
One of my test required to send some records back as json... seem really difficult to send a collection of records as json.. I found previous forum posts asking the same question a while back but nothing recently.
Is there any way to send a bunch of records as json?
Thanks
Ben