I am trying to use SSL with PDO and PDO MySQL but receiving a “PHP Fatal error: Undefined class constant ‘MYSQL_ATTR_SSL_CA'” for:
$this->db = new PDO(
"mysql:host=".$this->hostname.";dbname=".$this->database,
$this->username,
$this->password,
array(
PDO::ATTR_PERSISTENT => true,
PDO::MYSQL_ATTR_SSL_CA => "path/to/mysql-ssl-ca-cert.pem"
)
);
I have made sure that pdo_mysql is installed using phpinfo() and have had no problems using the code without SSL. I am on Ubuntu 3.9 using PHP 5.3.6-13. I have tried using other MYSQL_ATTR_.. and receive a similar error. Any thoughts on what might be happening?
PDO::MYSQL_ATTR_SSL_CAwas defined as a constant 5.3.7 onwards.You can look this up in the documentation: http://php.net/manual/en/ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-ca