我正在使用 cakephp 2.2.1 并尝试使用 cakedc 用户插件,当我尝试创建用户时出现以下错误,任何人都可以提供一些提示或建议来解决此错误 - 我已经使用迁移插件加载了所有表。提前致谢 :)。
2013-04-07 06:31:33 Error: [PDOException] SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'register' at line 1
#0 C:\wamp\www\toppin\lib\Cake\Model\Datasource\DboSource.php(459): PDOStatement->execute(Array)
#1 C:\wamp\www\toppin\lib\Cake\Model\Datasource\DboSource.php(425): DboSource->_execute('register', Array)
#2 C:\wamp\www\toppin\lib\Cake\Model\Datasource\DboSource.php(669): DboSource->execute('register', Array, Array)
#3 C:\wamp\www\toppin\lib\Cake\Model\Datasource\DboSource.php(611): DboSource->fetchAll('register', Array, Array)
#4 C:\wamp\www\toppin\lib\Cake\Model\Model.php(788): DboSource->query('register', Array, Object(User))
#5 C:\wamp\www\toppin\app\Plugin\Users\Controller\UsersController.php(331): Model->__call('register', Array)
#6 C:\wamp\www\toppin\app\Plugin\Users\Controller\UsersController.php(331): User->register(Array)
#7 [internal function]: UsersController->add()
#8 C:\wamp\www\toppin\lib\Cake\Controller\Controller.php(485): ReflectionMethod->invokeArgs(Object(UsersController), Array)
#9 C:\wamp\www\toppin\lib\Cake\Routing\Dispatcher.php(186): Controller->invokeAction(Object(CakeRequest))
#10 C:\wamp\www\toppin\lib\Cake\Routing\Dispatcher.php(161): Dispatcher->_invoke(Object(UsersController), Object(CakeRequest), Object(CakeResponse))
#11 C:\wamp\www\toppin\app\webroot\index.php(92): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#12 {main}
添加功能:
public function add() {
if ($this->Auth->user()) {
$this->Session->setFlash(__d('users', 'You are already registered and logged in!'));
$this->redirect('/');
}
if (!empty($this->request->data)) {
$user = $this->User->register($this->request->data);
if ($user !== false) {
$this->_sendVerificationEmail($this->User->data);
$this->Session->setFlash(__d('users', 'Your account has been created. You should receive an e-mail shortly to authenticate your account. Once validated you will be able to login.'));
$this->redirect(array('action' => 'login'));
} else {
unset($this->request->data[$this->modelClass]['password']);
unset($this->request->data[$this->modelClass]['temppassword']);
$this->Session->setFlash(__d('users', 'Your account could not be created. Please, try again.'), 'default', array('class' => 'message warning'));
}
}
}