メソッドを呼び出して、findAll
4 つのフィールドを取得しています$owned
。つまり、テーブルからレコードを取得した後、結果のデータレコードには所有フィールドが含まれている必要があります。また、$owned
フィールドは、ユーザーがグループの所有者であるかどうかに基づいて動的です。使ってみafterFind
ました。しかし、それも機能していません。驚くべきことに、属性では$owned
なくオブジェクトに属性を追加しています。CJSON::encode($model)
出力を表示するためにコントローラーで使用して$owned
います。フィールドが表示されていません。以下はコードです
/**
*
* The followings are the available columns in table 'group':
* @property integer $id
* @property string $name
* @property string $created_at
* @property string $updated_at
*/
class Group extends CActiveRecord
{
//adding owned property for groups.true if user is owner
public $owned;
protected function afterFind()
{
parent::afterFind();
//if user is owner of group its true
$this->owned = true;
}