【发布时间】:2012-08-23 04:23:57
【问题描述】:
我对 Yii 还很陌生,有一个小问题,但无法解决。问题是,当我在我的一个模型(活动记录)中调用 Yii 时,$this->attributes = 'something';我收到错误“未定义属性“SiteController.attributes”。”
我在控制器中有这个:
public function actionIndex()
{
// Create new clients active record
$client = new Clients;
// Check if user send some request
if (isSet($_POST)){
switch($_POST["action"]){
case 'newClient':
$registered = $client::addClient($_POST);
}
}
// render the view
$this->render('landing',array(
// Objects
'client' => $client,
// Variables
'registered' => $registered,
));
return true;
}
模型中的这个:
public function addClient($data){
// Set data
$this->attributes = $data["Clients"];
$this->password = self::generatePassword(6);
// Proceed
$this->setScenario('insert');
return true;
}
功能当然不完整,但这是我得到错误的地方。我到底做错了什么?谢谢
【问题讨论】:
标签: php object activerecord yii