2

使用後

$model=Table::model()->findByPk($id);

使用できます

$p=$model->property;

プロパティ値を取得します。このプロパティはテーブルの列に対応していますが、テーブルの列ではない新しいプロパティを 1 つ追加したいと考えて$modelいます。出来ますか?

4

1 に答える 1

2

はい、可能です。後のモデルでは

<?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;

テーブルに存在する属性を参照するのと同じように、これらを参照できます。

于 2013-06-25T09:30:34.240 に答える