使用後
$model=Table::model()->findByPk($id);
使用できます
$p=$model->property;
プロパティ値を取得します。このプロパティはテーブルの列に対応していますが、テーブルの列ではない新しいプロパティを 1 つ追加したいと考えて$model
います。出来ますか?
はい、可能です。後のモデルでは
<?php
/**
* This is the model class for table "{{table}}".
*
* The followings are the available columns in table '{{table}}':
* @property integer $id
.......
*/
class Table extends CActiveRecord
{
一部で、クラスのカスタム プロパティを定義できます。このような:
class Table extends CActiveRecord
{
public $aPublicAttribute;
private $_aPivateAttribute;
テーブルに存在する属性を参照するのと同じように、これらを参照できます。