为什么忽略MYSQLI_CLIENT_FOUND_ROWS?

时间:2014-02-04 18:57:17

标签: php mysql mysqli

我正在使用mysqli将我的php代码连接到mysql,我正在使用MYSQLI_CLIENT_FOUND_ROWS选项来确保我的UPDATE语句将返回非零,即使他们尝试使用与已存在的值相同的更新记录。

$mysqli->real_connect(
            $this->DB_HOST,
            $this->DB_USERNAME,
            $this->DB_PASSWORD,
            $this->DB_DATABASE,
            3306,
            null,
            MYSQLI_CLIENT_FOUND_ROWS
    );

我有一个它工作的盒子:php53,mysql 5.1.54-log - MySQL社区服务器(GPL) 我现在安装了一个不起作用的新盒子:php 53,mysql 5.1.44 - 源代码分发

在第一个框中,语句'affected_rows'为1.在第二个框中,它为0.

非工作箱的软件信息:

Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_perl/2.0.4 Perl/v5.10.1

phpinfo for non working box(我希望这是足够的细节):     MySQL的

MySQL Support   enabled
Active Persistent Links 0
Active Links    0
Client API version  5.1.44
MYSQL_MODULE_TYPE   external
MYSQL_SOCKET    /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
MYSQL_INCLUDE   -I/Applications/XAMPP/xamppfiles/include/mysql
MYSQL_LIBS  -L/Applications/XAMPP/xamppfiles/lib/mysql -lmysqlclient
Directive   Local Value Master Value
mysql.allow_local_infile    On  On
mysql.allow_persistent  On  On
mysql.connect_timeout   60  60
mysql.default_host  no value    no value
mysql.default_password  no value    no value
mysql.default_port  no value    no value
mysql.default_socket    /tmp/mysql.sock /tmp/mysql.sock
mysql.default_user  no value    no value
mysql.max_links Unlimited   Unlimited
mysql.max_persistent    Unlimited   Unlimited
mysql.trace_mode    Off Off
mysqli

MysqlI Support  enabled
Client API library version  5.1.44
Active Persistent Links 0
Inactive Persistent Links   0
Active Links    0
Client API header version   5.1.44
MYSQLI_SOCKET   /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
Directive   Local Value Master Value
mysqli.allow_local_infile   On  On
mysqli.allow_persistent On  On
mysqli.default_host no value    no value
mysqli.default_port 3306    3306
mysqli.default_pw   no value    no value
mysqli.default_socket   /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
mysqli.default_user no value    no value
mysqli.max_links    Unlimited   Unlimited
mysqli.max_persistent   Unlimited   Unlimited
mysqli.reconnect    Off Off

工作框的php信息:

mysql
MySQL Support   enabled
Active Persistent Links 0
Active Links    0
Client API version  5.1.54
MYSQL_MODULE_TYPE   no value
MYSQL_SOCKET    /usr/local/zend/mysql/tmp/mysql.sock
MYSQL_INCLUDE   no value
MYSQL_LIBS  no value

Directive   Local Value Master Value
mysql.allow_local_infile    On  On
mysql.allow_persistent  On  On
mysql.connect_timeout   60  60
mysql.default_host  no value    no value
mysql.default_password  no value    no value
mysql.default_port  no value    no value
mysql.default_socket    /usr/local/zend/mysql/tmp/mysql.sock    /usr/local/zend/mysql/tmp/mysql.sock
mysql.default_user  zend    zend
mysql.max_links Unlimited   Unlimited
mysql.max_persistent    Unlimited   Unlimited
mysql.trace_mode    Off Off

mysqli

MysqlI Support  enabled
Client API library version  5.1.54
Active Persistent Links 0
Inactive Persistent Links   0
Active Links    0
Client API header version   5.1.54
MYSQLI_SOCKET   /usr/local/zend/mysql/tmp/mysql.sock

Directive   Local Value Master Value
mysqli.allow_local_infile   On  On
mysqli.allow_persistent On  On
mysqli.default_host no value    no value
mysqli.default_port 3306    3306
mysqli.default_pw   no value    no value
mysqli.default_socket   /usr/local/zend/mysql/tmp/mysql.sock    /usr/local/zend/mysql/tmp/mysql.sock
mysqli.default_user zend    zend
mysqli.max_links    Unlimited   Unlimited
mysqli.max_persistent   Unlimited   Unlimited
mysqli.reconnect    Off Off

任何想法为什么?我在这里敲我的头......两个mysql之间的微小构建数字差异是不可能的原因......

2 个答案:

答案 0 :(得分:0)

当使用启用了mysqlnd的php而不是mysql本机客户端时,它运行良好。但由于种种原因,我无法重建PHP。我最终通过macports(端口安装php53 php53-mysql)安装了一个新的PHP来解决它。

答案 1 :(得分:0)

而不是

MYSQLI_CLIENT_FOUND_ROWS

尝试使用整数

2

像这样:

$mysqli->real_connect(
        $this->DB_HOST,
        $this->DB_USERNAME,
        $this->DB_PASSWORD,
        $this->DB_DATABASE,
        3306,
        null,
        2
);

它为我解决了问题......