我有一个基于Web的PHP电子邮件客户端( Roundcube ),我安装在UNIX服务器上,马上就产生了这个错误:
Fatal error: Undefined class constant 'MYSQL_ATTR_FOUND_ROWS' in /path/to/file.php on line 134
这是这行代码:
$result[PDO::MYSQL_ATTR_FOUND_ROWS] = true;
本地在我的Windows安装它工作正常,所以我比较这两个PDO类:
<?php ReflectionClass::export('PDO');
活的UNIX服务器上不存在MYSQL_ATTR_FOUND_ROWS属性和其他一些属性。 我通过对未知值进行硬编码做了一个快速修补,并且效果很好,但是我不能确定没有更多的错误(我们也不想使用被黑客入侵的版本)。
PDO类是绝对加载的,我们实际上需要启用它,以便首先安装带有MySQL / PDO选项的Roundcube。 似乎现场服务器的PDO类需要更新,我猜? 我没有直接控制现场服务器,但我可以给那些做的人的指示。 任何人都可以帮我弄清楚必须做什么?
这里是统计信息:
PDO类debugging输出:
Class [ <internal:PDO> class PDO ] { - Constants [86] { Constant [ integer PARAM_BOOL ] { 5 } Constant [ integer PARAM_NULL ] { 0 } Constant [ integer PARAM_INT ] { 1 } Constant [ integer PARAM_STR ] { 2 } Constant [ integer PARAM_LOB ] { 3 } Constant [ integer PARAM_STMT ] { 4 } Constant [ integer PARAM_INPUT_OUTPUT ] { -2147483648 } Constant [ integer PARAM_EVT_ALLOC ] { 0 } Constant [ integer PARAM_EVT_FREE ] { 1 } Constant [ integer PARAM_EVT_EXEC_PRE ] { 2 } Constant [ integer PARAM_EVT_EXEC_POST ] { 3 } Constant [ integer PARAM_EVT_FETCH_PRE ] { 4 } Constant [ integer PARAM_EVT_FETCH_POST ] { 5 } Constant [ integer PARAM_EVT_NORMALIZE ] { 6 } Constant [ integer FETCH_LAZY ] { 1 } Constant [ integer FETCH_ASSOC ] { 2 } Constant [ integer FETCH_NUM ] { 3 } Constant [ integer FETCH_BOTH ] { 4 } Constant [ integer FETCH_OBJ ] { 5 } Constant [ integer FETCH_BOUND ] { 6 } Constant [ integer FETCH_COLUMN ] { 7 } Constant [ integer FETCH_CLASS ] { 8 } Constant [ integer FETCH_INTO ] { 9 } Constant [ integer FETCH_FUNC ] { 10 } Constant [ integer FETCH_GROUP ] { 65536 } Constant [ integer FETCH_UNIQUE ] { 196608 } Constant [ integer FETCH_KEY_PAIR ] { 12 } Constant [ integer FETCH_CLASSTYPE ] { 262144 } Constant [ integer FETCH_SERIALIZE ] { 524288 } Constant [ integer FETCH_PROPS_LATE ] { 1048576 } Constant [ integer FETCH_NAMED ] { 11 } Constant [ integer ATTR_AUTOCOMMIT ] { 0 } Constant [ integer ATTR_PREFETCH ] { 1 } Constant [ integer ATTR_TIMEOUT ] { 2 } Constant [ integer ATTR_ERRMODE ] { 3 } Constant [ integer ATTR_SERVER_VERSION ] { 4 } Constant [ integer ATTR_CLIENT_VERSION ] { 5 } Constant [ integer ATTR_SERVER_INFO ] { 6 } Constant [ integer ATTR_CONNECTION_STATUS ] { 7 } Constant [ integer ATTR_CASE ] { 8 } Constant [ integer ATTR_CURSOR_NAME ] { 9 } Constant [ integer ATTR_CURSOR ] { 10 } Constant [ integer ATTR_ORACLE_NULLS ] { 11 } Constant [ integer ATTR_PERSISTENT ] { 12 } Constant [ integer ATTR_STATEMENT_CLASS ] { 13 } Constant [ integer ATTR_FETCH_TABLE_NAMES ] { 14 } Constant [ integer ATTR_FETCH_CATALOG_NAMES ] { 15 } Constant [ integer ATTR_DRIVER_NAME ] { 16 } Constant [ integer ATTR_STRINGIFY_FETCHES ] { 17 } Constant [ integer ATTR_MAX_COLUMN_LEN ] { 18 } Constant [ integer ATTR_EMULATE_PREPARES ] { 20 } Constant [ integer ATTR_DEFAULT_FETCH_MODE ] { 19 } Constant [ integer ERRMODE_SILENT ] { 0 } Constant [ integer ERRMODE_WARNING ] { 1 } Constant [ integer ERRMODE_EXCEPTION ] { 2 } Constant [ integer CASE_NATURAL ] { 0 } Constant [ integer CASE_LOWER ] { 2 } Constant [ integer CASE_UPPER ] { 1 } Constant [ integer NULL_NATURAL ] { 0 } Constant [ integer NULL_EMPTY_STRING ] { 1 } Constant [ integer NULL_TO_STRING ] { 2 } Constant [ string ERR_NONE ] { 00000 } Constant [ integer FETCH_ORI_NEXT ] { 0 } Constant [ integer FETCH_ORI_PRIOR ] { 1 } Constant [ integer FETCH_ORI_FIRST ] { 2 } Constant [ integer FETCH_ORI_LAST ] { 3 } Constant [ integer FETCH_ORI_ABS ] { 4 } Constant [ integer FETCH_ORI_REL ] { 5 } Constant [ integer CURSOR_FWDONLY ] { 0 } Constant [ integer CURSOR_SCROLL ] { 1 } Constant [ integer MYSQL_ATTR_USE_BUFFERED_QUERY ] { 1000 } Constant [ integer MYSQL_ATTR_LOCAL_INFILE ] { 1001 } Constant [ integer MYSQL_ATTR_INIT_COMMAND ] { 1002 } Constant [ integer MYSQL_ATTR_DIRECT_QUERY ] { 1003 } Constant [ integer MYSQL_ATTR_FOUND_ROWS ] { 1004 } Constant [ integer MYSQL_ATTR_IGNORE_SPACE ] { 1005 } Constant [ integer MYSQL_ATTR_SSL_KEY ] { 1006 } Constant [ integer MYSQL_ATTR_SSL_CERT ] { 1007 } Constant [ integer MYSQL_ATTR_SSL_CA ] { 1008 } Constant [ integer MYSQL_ATTR_SSL_CAPATH ] { 1009 } Constant [ integer MYSQL_ATTR_SSL_CIPHER ] { 1010 } Constant [ integer ODBC_ATTR_USE_CURSOR_LIBRARY ] { 1000 } Constant [ integer ODBC_ATTR_ASSUME_UTF8 ] { 1001 } Constant [ integer ODBC_SQL_USE_IF_NEEDED ] { 0 } Constant [ integer ODBC_SQL_USE_DRIVER ] { 2 } Constant [ integer ODBC_SQL_USE_ODBC ] { 1 } } - Static properties [0] { } - Static methods [1] { Method [ <internal:PDO> static public method getAvailableDrivers ] { - Parameters [0] { } } } - Properties [0] { } - Methods [16] { Method [ <internal:PDO, ctor> public method __construct ] { - Parameters [4] { Parameter #0 [ <required> $dsn ] Parameter #1 [ <required> $username ] Parameter #2 [ <required> $passwd ] Parameter #3 [ <optional> $options ] } } Method [ <internal:PDO> public method prepare ] { - Parameters [2] { Parameter #0 [ <required> $statment ] Parameter #1 [ <optional> $options ] } } Method [ <internal:PDO> public method beginTransaction ] { - Parameters [0] { } } Method [ <internal:PDO> public method commit ] { - Parameters [0] { } } Method [ <internal:PDO> public method rollBack ] { - Parameters [0] { } } Method [ <internal:PDO> public method inTransaction ] { - Parameters [0] { } } Method [ <internal:PDO> public method setAttribute ] { - Parameters [2] { Parameter #0 [ <required> $attribute ] Parameter #1 [ <required> $value ] } } Method [ <internal:PDO> public method exec ] { - Parameters [1] { Parameter #0 [ <required> $query ] } } Method [ <internal:PDO> public method query ] { } Method [ <internal:PDO> public method lastInsertId ] { - Parameters [1] { Parameter #0 [ <optional> $seqname ] } } Method [ <internal:PDO> public method errorCode ] { - Parameters [0] { } } Method [ <internal:PDO> public method errorInfo ] { - Parameters [0] { } } Method [ <internal:PDO> public method getAttribute ] { - Parameters [1] { Parameter #0 [ <required> $attribute ] } } Method [ <internal:PDO> public method quote ] { - Parameters [2] { Parameter #0 [ <required> $string ] Parameter #1 [ <optional> $paramtype ] } } Method [ <internal:PDO> final public method __wakeup ] { - Parameters [0] { } } Method [ <internal:PDO> final public method __sleep ] { - Parameters [0] { } } } }
PDO类debugging输出:
Class [ <internal:PDO> class PDO ] { - Constants [77] { Constant [ integer PARAM_BOOL ] { 5 } Constant [ integer PARAM_NULL ] { 0 } Constant [ integer PARAM_INT ] { 1 } Constant [ integer PARAM_STR ] { 2 } Constant [ integer PARAM_LOB ] { 3 } Constant [ integer PARAM_STMT ] { 4 } Constant [ integer PARAM_INPUT_OUTPUT ] { -2147483648 } Constant [ integer PARAM_EVT_ALLOC ] { 0 } Constant [ integer PARAM_EVT_FREE ] { 1 } Constant [ integer PARAM_EVT_EXEC_PRE ] { 2 } Constant [ integer PARAM_EVT_EXEC_POST ] { 3 } Constant [ integer PARAM_EVT_FETCH_PRE ] { 4 } Constant [ integer PARAM_EVT_FETCH_POST ] { 5 } Constant [ integer PARAM_EVT_NORMALIZE ] { 6 } Constant [ integer FETCH_LAZY ] { 1 } Constant [ integer FETCH_ASSOC ] { 2 } Constant [ integer FETCH_NUM ] { 3 } Constant [ integer FETCH_BOTH ] { 4 } Constant [ integer FETCH_OBJ ] { 5 } Constant [ integer FETCH_BOUND ] { 6 } Constant [ integer FETCH_COLUMN ] { 7 } Constant [ integer FETCH_CLASS ] { 8 } Constant [ integer FETCH_INTO ] { 9 } Constant [ integer FETCH_FUNC ] { 10 } Constant [ integer FETCH_GROUP ] { 65536 } Constant [ integer FETCH_UNIQUE ] { 196608 } Constant [ integer FETCH_KEY_PAIR ] { 12 } Constant [ integer FETCH_CLASSTYPE ] { 262144 } Constant [ integer FETCH_SERIALIZE ] { 524288 } Constant [ integer FETCH_PROPS_LATE ] { 1048576 } Constant [ integer FETCH_NAMED ] { 11 } Constant [ integer ATTR_AUTOCOMMIT ] { 0 } Constant [ integer ATTR_PREFETCH ] { 1 } Constant [ integer ATTR_TIMEOUT ] { 2 } Constant [ integer ATTR_ERRMODE ] { 3 } Constant [ integer ATTR_SERVER_VERSION ] { 4 } Constant [ integer ATTR_CLIENT_VERSION ] { 5 } Constant [ integer ATTR_SERVER_INFO ] { 6 } Constant [ integer ATTR_CONNECTION_STATUS ] { 7 } Constant [ integer ATTR_CASE ] { 8 } Constant [ integer ATTR_CURSOR_NAME ] { 9 } Constant [ integer ATTR_CURSOR ] { 10 } Constant [ integer ATTR_ORACLE_NULLS ] { 11 } Constant [ integer ATTR_PERSISTENT ] { 12 } Constant [ integer ATTR_STATEMENT_CLASS ] { 13 } Constant [ integer ATTR_FETCH_TABLE_NAMES ] { 14 } Constant [ integer ATTR_FETCH_CATALOG_NAMES ] { 15 } Constant [ integer ATTR_DRIVER_NAME ] { 16 } Constant [ integer ATTR_STRINGIFY_FETCHES ] { 17 } Constant [ integer ATTR_MAX_COLUMN_LEN ] { 18 } Constant [ integer ATTR_EMULATE_PREPARES ] { 20 } Constant [ integer ATTR_DEFAULT_FETCH_MODE ] { 19 } Constant [ integer ERRMODE_SILENT ] { 0 } Constant [ integer ERRMODE_WARNING ] { 1 } Constant [ integer ERRMODE_EXCEPTION ] { 2 } Constant [ integer CASE_NATURAL ] { 0 } Constant [ integer CASE_LOWER ] { 2 } Constant [ integer CASE_UPPER ] { 1 } Constant [ integer NULL_NATURAL ] { 0 } Constant [ integer NULL_EMPTY_STRING ] { 1 } Constant [ integer NULL_TO_STRING ] { 2 } Constant [ string ERR_NONE ] { 00000 } Constant [ integer FETCH_ORI_NEXT ] { 0 } Constant [ integer FETCH_ORI_PRIOR ] { 1 } Constant [ integer FETCH_ORI_FIRST ] { 2 } Constant [ integer FETCH_ORI_LAST ] { 3 } Constant [ integer FETCH_ORI_ABS ] { 4 } Constant [ integer FETCH_ORI_REL ] { 5 } Constant [ integer CURSOR_FWDONLY ] { 0 } Constant [ integer CURSOR_SCROLL ] { 1 } Constant [ integer MYSQL_ATTR_USE_BUFFERED_QUERY ] { 1000 } Constant [ integer MYSQL_ATTR_LOCAL_INFILE ] { 1001 } Constant [ integer MYSQL_ATTR_INIT_COMMAND ] { 1002 } Constant [ integer MYSQL_ATTR_READ_DEFAULT_FILE ] { 1003 } Constant [ integer MYSQL_ATTR_READ_DEFAULT_GROUP ] { 1004 } Constant [ integer MYSQL_ATTR_MAX_BUFFER_SIZE ] { 1005 } Constant [ integer MYSQL_ATTR_DIRECT_QUERY ] { 1006 } } - Static properties [0] { } - Static methods [1] { Method [ <internal:PDO> static public method getAvailableDrivers ] { - Parameters [0] { } } } - Properties [0] { } - Methods [16] { Method [ <internal:PDO, ctor> public method __construct ] { - Parameters [4] { Parameter #0 [ <required> $dsn ] Parameter #1 [ <required> $username ] Parameter #2 [ <required> $passwd ] Parameter #3 [ <optional> $options ] } } Method [ <internal:PDO> public method prepare ] { - Parameters [2] { Parameter #0 [ <required> $statment ] Parameter #1 [ <optional> $options ] } } Method [ <internal:PDO> public method beginTransaction ] { - Parameters [0] { } } Method [ <internal:PDO> public method commit ] { - Parameters [0] { } } Method [ <internal:PDO> public method rollBack ] { - Parameters [0] { } } Method [ <internal:PDO> public method inTransaction ] { - Parameters [0] { } } Method [ <internal:PDO> public method setAttribute ] { - Parameters [2] { Parameter #0 [ <required> $attribute ] Parameter #1 [ <required> $value ] } } Method [ <internal:PDO> public method exec ] { - Parameters [1] { Parameter #0 [ <required> $query ] } } Method [ <internal:PDO> public method query ] { } Method [ <internal:PDO> public method lastInsertId ] { - Parameters [1] { Parameter #0 [ <optional> $seqname ] } } Method [ <internal:PDO> public method errorCode ] { - Parameters [0] { } } Method [ <internal:PDO> public method errorInfo ] { - Parameters [0] { } } Method [ <internal:PDO> public method getAttribute ] { - Parameters [1] { Parameter #0 [ <required> $attribute ] } } Method [ <internal:PDO> public method quote ] { - Parameters [2] { Parameter #0 [ <required> $string ] Parameter #1 [ <optional> $paramtype ] } } Method [ <internal:PDO> final public method __wakeup ] { - Parameters [0] { } } Method [ <internal:PDO> final public method __sleep ] { - Parameters [0] { } } } }
这里是php.ini文件的馅饼链接(内容太大去添加到这个职位): 第1 部分 , 第2部分
为了将这些缺失的属性放到活动服务器的PDO库中,我们需要做的最低要求是什么? 事实上,这里甚至发生了什么,他们为什么如此不同呢?
所以你只是强迫我重build我的PHP 没有mysqlnd (就像你的构build,只使用libmysql后端 )来检查我的理论。 幸运的是,我有一个Gentoo安装快速!
正如我所料,没有mysqlnd,PDO类中根本没有任何PDO :: MYSQL_ *常量。 因此,为了使它们到位,你应该使用mysqlnd:重新编译PHP,或者可能得到一个pdo_mysqlnd.so(或php_mysql.sobuild立在mysqlnd上)扩展名并加载它。
Windows的PHP二进制似乎即将与mysqlnd编译。
顺便说一下,mysqlnd是PHP 5.4.0的默认后端。
缺less的常量在ext/pdo_mysql/pdo_mysql.c ,这取决于您的系统在以下任一模块中都可用:
pdo_mysqlnd.so pdo_mysql.so 当你运行php -m你将能够看到是否有任何这些模块实际加载; 你会寻找pdo_mysql模块。
要将模块针对mysqlnd编译到PHP二进制文件中:
./config.nice --enable-mysqlnd --with-pdo-mysql=mysqlnd make && make install