我想创建一个用户注册页面,但发现很难。我无法写入数据库,但可以毫无问题地从中读取。当我想通过 Active Error 插入时,我也没有收到任何错误。这是我正在做的事情的例子
public function actionIndex()
{
$user = new User;
$user->username = 'irakli';
$user->save();
$this->render('index');
}
此代码无法正常工作,但我完全没有收到任何错误。 请注意
$record=User::model()->findByAttributes(array('username'=>$this->username));
$data = $record->id;
$this->render('index', array('data'=>$data));
工作正常。
最佳答案
这应该有助于调试问题。
$user = new User;
$user->username = 'irakli';
if (! $user->save() ) {
print_r( $user->getErrors() );
}
关于php - Yii 事件记录不能写但可以读,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9537018/