$db = new PDO('mysql:dbname=xnews;host=localhost;port=' . $LOCAL_DB_PORT,
$LOCAL_DB_USER,
$LOCAL_DB_PASS,
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'")
);
Fatal error: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND'
In fact, the MYSQL_ATTR_INIT_COMMAND is 1002. But at some times the php can not recognize it. The one reason is that you have not installed php-mysql for php_module.
If you use yum to install php and mysql, then you may use
sudo yum install php-mysql
sudo service httpd restart
or you may compile your php with the
--with-pdo-mysql
optionThat is OK. Now you may access the constant MYSQL_ATTR_INIT_COMMAND. Good luck to you.
No comments:
Post a Comment