The question is: How do I get JSON out of Yii?
In the case of a single model, that’s easy. We can just use CJSON::encode().
But what if we have, for example, $message (a Message model queried with ->find()) and $attachments (an array of Attachment models queried with ->findAll()). If they were just arrays, we’d say:
$message['attachments'] = $attachments; echo json_encode($message);
but they aren’t arrays. What’s the Yii CActiveRecord CEquivelent?