$这个 - > Auth->登录()创建返回1行的正确的查询,但无法IF检查(服务器具体问题) [英] $this->Auth->login() creates correct query that returns 1 row, but fails IF check (server specific issue)

查看:85
本文介绍了$这个 - > Auth->登录()创建返回1行的正确的查询,但无法IF检查(服务器具体问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有我们要移动到新的服务器的站点。一切旧服务器上正常工作。这是一个网站仅仅是一个开始,所以它的pretty裸机。

We have a site that we're moving to a new server. Everything worked fine on the old server. It's just the start of a site, so it's pretty bare-bones.

当移动到我们的新的服务器,试图登录不再起作用。但是 - 根据debugKit,所产生的查询 $这个 - > Auth->登录()

When moving to our new server, trying to log-in no longer works. BUT - according to debugKit, the query generated by $this->Auth->login():

SELECT `User`.`id`, `User`.`name`, `User`.`email`, `User`.`username`, `User`.`password`, `User`.`role`, `User`.`created`, `User`.`modified` 
FROM `shopping_main`.`users` AS `User` 
WHERE `User`.`username` = 'another' 
AND `User`.`password` = '3813dd3a5eeb39c857d56f9ae58ec7f8237e5eb3' 
LIMIT 1

时返回1行 - 但这个如果块失败的:

IS returning 1 row - yet this if block fails:

if ($this->Auth->login()) {
    $this->Session->setFlash(__('You are now logged in.'));
} else {
    $this->Session->setFlash(__('Invalid username or password, try again'));
}

PDO是安装在两个(同一版本) - 不知道这重要的,但我们已经有奇怪的问题之前瓦特/那

PDO is installed on both (same version) - not sure if that matters, but we've had weird issues before w/ that.

在做一个全新的安装CakePHP的2.2稳定,一切都亮起绿色(数据库连接,modrewrite ......等等等等。)

When doing a fresh install of CakePHP 2.2 stable, everything lights up green (database connection, modrewrite...etc etc.)

我还以为有什么问题我们的数据,或code ...等,但是 - 这是同样的数据,同样code,这是由事实验证它返回1一行。

I would have thought there was something wrong with our data, or code...etc, but - it's the same data, the same code, and that's verified by the fact that it DOES return 1 row.

下面是我最近 $组件数组中的AppController的:

Below is my most recent $components array in the AppController:

public $components = array(
    'DebugKit.Toolbar',
    'Session',
    'Cookie',
    'Auth' => array(
        'loginRedirect' => array('controller' => 'dashboard', 'action' => 'index', 'admin'=>true),
        'logoutRedirect' => array('controller' => 'users', 'action' => 'login', 'admin'=>true)
    )
);


更新:

根据我们的服务器的家伙,我们遇到的问题的服务器是PECL唯一一个龙头安装 - 当他删除它,登录工作。 (我们需要的服务器,其他的事情上 - 为什么/什么原因,为了保持我们的登录无法正常工作)

According to our server guy, the server we're having the issue on is the only one with PECL intalled - when he removed it, the login worked. (We need it on the server for other things - why/what would cause that to keep our login from working?)

推荐答案

由原始的海报的答案(我):

根据我们的服务器的家伙,有两种方法来加载PDO,首先是通过使用easyapache安装PDO PHP扩展。第二个是通过PECL安装PDO,它似乎有问题的模块是不同的。

According to our server guy, "There are two ways to load PDO. The first is by using easyapache to install the PDO php extension. The second is by installing the PDO via PECL. It appears that the modules in question are different."

显然,在此服务器上它有PECL而非正常easyapache PDO的。当他删除了,并重新启动/与easyapache PDO重置,一切都很好。

Apparently, this server had PECL on it instead of the normal easyapache PDO. When he removed that, and restarted/reset it with the easyapache PDO, everything worked great.

所以 - 听起来像CakePHP所需的正常PDO

So - sounds like CakePHP requires the "normal" PDO.

解开了谜底。

如果您有PECL相反,你可以使用此解决方法:

If you have PECL instead, you can use this workaround:


  1. 在您的数据源文件夹中创建一个文件HpMysql.php并添加此code /类:<一href=\"https://github.com/lorenzo/HipHop/blob/master/Model/Datasource/Database/HpMysql.php\">https://github.com/lorenzo/HipHop/blob/master/Model/Datasource/Database/HpMysql.php

您database.php中数据源更改为HpMysql

Change your database.php 'datasource' to 'HpMysql'

这篇关于$这个 - &GT; Auth-&GT;登录()创建返回1行的正确的查询,但无法IF检查(服务器具体问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆