【问题标题】:cakePHP illegal offset typecakePHP 非法偏移类型
【发布时间】:2012-03-21 17:04:32
【问题描述】:

我是 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

【问题讨论】:

  • 不,我应该检查一下。我正在运行2.1。从教程中获取代码以运行的任何建议?我对蛋糕很陌生,所以我觉得我要重新开始 php ......基本上我一无所知。

标签: php mysql cakephp


【解决方案1】:

我建议您遵循

上的最新教程

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

由于您使用的是 cakephp 2.1,因此应该完全遵循您的设置。您现在尝试关注的是 cakephp1.2,它是在 2007 年编写的,所以我怀疑它对您有用。

【讨论】:

    猜你喜欢
    • 2011-01-12
    • 2013-03-24
    • 2019-05-03
    • 1970-01-01
    • 1970-01-01
    • 2020-10-21
    • 2019-07-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多