I have a web-based PHP email client (Roundcube) that I installed on a UNIX server, and right off the bat it produced this error:
Fatal error: Undefined class constant 'MYSQL_ATTR_FOUND_ROWS' in /path/to/file.php on line 134
It's this line of code:
$result[PDO::MYSQL_ATTR_FOUND_ROWS] = true;
Locally on my Windows installation it works fine, so I compared the two PDO classes with this:
<?php ReflectionClass::export('PDO');
The MYSQL_ATTR_FOUND_ROWS
property and some others weren't present on the live UNIX server. I did a quick patch by hardcoding the unknown value and it worked great, but I can't be sure there aren't more bugs (and we don't want to use a hacked version anyways).
The PDO class is definitely loaded, we actually needed to enable it in order to install Roundcube with the MySQL/PDO option in the first place. It seems like the live server's PDO class needs to be updated, I'm guessing? I do not have direct control over the live server, but I can give instructions to the guy who does. Can anyone help me figure out what must be done?
Here are the stats:
Local Windows Apache Server (working), PHP Version 5.3.8
PDO class debug output:
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] {
}
}
}
}
Live UNIX Apache server (not working), PHP Version 5.3.18
PDO class debug output:
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] {
}
}
}
}
Here are links to pasties of the php.ini file (content was too large go to add to this post): Part 1, Part 2
What's the minimum we need to do to get these missing properties into the live server's PDO library? Actually, what is even going on here, why are they so different?
The missing constant gets declared in
ext/pdo_mysql/pdo_mysql.c
, which depending on your system is available in either of the following modules:pdo_mysqlnd.so
pdo_mysql.so
When you run
php -m
you will be able to see if any of those modules is actually loaded; you would be looking for thepdo_mysql
module.To compile the module against
mysqlnd
into the PHP binary itself:So you just forced me to rebuild my PHP without mysqlnd (like your build, using only libmysql backend) to check my theory. Fortunately I have a Gentoo installation to do it quick!
As I expected, without mysqlnd, there are NO ANY PDO::MYSQL_* constants in PDO class at all. So to get them in place, you should use mysqlnd: either recompile PHP, or possibly get an pdo_mysqlnd.so (or php_mysql.so built against mysqlnd) extension and load it.
Windows PHP binary seems coming compiled with mysqlnd.
By the way, mysqlnd is default backend as of PHP 5.4.0.