Skip to content

Instantly share code, notes, and snippets.

@peerax
Created February 20, 2017 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peerax/a8f1a1257b7fca8542a907d8b6b2ea65 to your computer and use it in GitHub Desktop.
Save peerax/a8f1a1257b7fca8542a907d8b6b2ea65 to your computer and use it in GitHub Desktop.
Yii Active record to json
$models=Bla::model()->findAll();
$data=array_map(create_function('$m','return $m->getAttributes(array(\'id\',\'name\'));'),$models);
echo json_encode($data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment