cakePHP非法偏移类型

时间:2012-03-21 17:04:33

标签: php mysql cakephp

我是cakephp的新手,并遵循本教程中的用户身份验证系统

http://bakery.cakephp.org/articles/SeanCallan/2007/04/17/simple-form-authentication-in-1-2-x-x

我唯一改变的是login.ctp文件。我改变了指针

 $form-> 

 $this->Form->

我遇到两个错误,我无法弄清楚原因。这是第一个

警告(2):非法偏移类型[CORE \ Cake \ Model \ Model.php,第2603行]

这是它显示的代码/上下文      if($ type!=='all'){             if($ this-> findMethods [$ type] === true){

$type   =   array(
'username' => '',
'password' => '*****'
)
$query  =   array(
'conditions' => null,
'fields' => null,
'joins' => array(),
'limit' => null,
'offset' => null,
'order' => null,
'page' => (int) 1,
'group' => null,
'callbacks' => true,
(int) 0 => 'id',
(int) 1 => 'username'
)
$this   =   object(User) {}

此信息也已显示

Model::buildQuery() - CORE\Cake\Model\Model.php, line 2603
Model::find() - CORE\Cake\Model\Model.php, line 2562
User::validateLogin() - APP\Model\User.php, line 9
UsersController::login() - APP\Controller\UsersController.php, line 21
ReflectionMethod::invokeArgs() - [internal], line ??
Controller::invokeAction() - CORE\Cake\Controller\Controller.php, line 484
Dispatcher::_invoke() - CORE\Cake\Routing\Dispatcher.php, line 104
Dispatcher::dispatch() - CORE\Cake\Routing\Dispatcher.php, line 86
[main] - APP\webroot\index.php, line 96

这是第二个错误

警告(2):非法偏移类型[CORE \ Cake \ Model \ Model.php,第2579行]

这是它显示的代码

   return $results;
     } else {
        if ($this->findMethods[$type] === true) {

$type   =   array(
'username' => '',
'password' => '*****'
 )
 $query =   array(
'conditions' => null,
'fields' => null,
'joins' => array(),
'limit' => null,
'offset' => null,
'order' => array(
),
'page' => (int) 1,
'group' => null,
'callbacks' => true,
(int) 0 => 'id',
(int) 1 => 'username'
)
$results    =   array(
(int) 0 => array(
)
)
$this   =   object(User) {}

以下是其他信息

Model::find() - CORE\Cake\Model\Model.php, line 2579
User::validateLogin() - APP\Model\User.php, line 9
UsersController::login() - APP\Controller\UsersController.php, line 21
ReflectionMethod::invokeArgs() - [internal], line ??
Controller::invokeAction() - CORE\Cake\Controller\Controller.php, line 484
Dispatcher::_invoke() - CORE\Cake\Routing\Dispatcher.php, line 104
Dispatcher::dispatch() - CORE\Cake\Routing\Dispatcher.php, line 86
[main] - APP\webroot\index.php, line 96

1 个答案:

答案 0 :(得分:2)

我建议您按照

中最近的教程进行操作

http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html

因为你正在使用cakephp 2.1,所以应该完全遵循你的设置。你现在要遵循的是cakephp1.2并于2007年编写,所以我怀疑它对你有用。

相关问题