Question

With a PHP web application, I'm encountering a fatal error with PDO::MYSQL_ATTR_MAX_BUFFER_SIZE, but only on very rare hosting plans. It's saying this constant is not available. How do I detect that it's not available and not use it?

I mean, I can use the if (!defined(...)) if/then check, but will this still get the fatal error on those systems where MYSQL_ATTR_MAX_BUFFER_SIZE is not compiled with PDO? Note that there's a known bug regarding MYSQL_ATTR_MAX_BUFFER_SIZE and mysqlnd, where it's not compiled in cases where mysqlnd is installed. The bug is marked as "won't fix".

Was it helpful?

Solution

You are not using defined() properly, is my guess. You need to provide it a string.

if( defined( 'PDO::MYSQL_ATTR_MAX_BUFFER_SIZE' ) ) // note the quotes
{
    // do something useful with PDO::MYSQL_ATTR_MAX_BUFFER_SIZE
}

The above example doesn't issue any notice/warning/error in my setup (PHP 5.3.20, in which PDO::MYSQL_ATTR_MAX_BUFFER_SIZE is not defined), using error_reporting( E_ALL | E_STRICT ).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top