我正在尝试按照this教程和运行该命令时配置doctrine: ./vendor/bin/doctrine-module orm:validate-schema我收到错误:
第19行的var / www / CommunicationApp / config / autoload / global.php中未定义的类常量'MYSQL_ATTR_INIT_COMMAND'
这是global.php文件:
<?php
/**
* Global Configuration Override
*
* You can use this file for overriding configuration values from modules, etc.
* You would place values in here that are agnostic to the environment and not
* sensitive to security.
*
* @NOTE: In practice, this file will typically be INCLUDED in your source
* control, so do not include passwords or other sensitive information in this
* file.
*/
return array(
'db' => array(
'driver' => 'Pdo',
'dsn' => 'mysql:dbname=zf2tutorial;host=localhost',
'driver_options' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
),
),
'service_manager' => array(
'factories' => array(
'Zend\Db\Adapter\Adapter'
=> 'Zend\Db\Adapter\AdapterServiceFactory',
),
),
);
我已经取消注释/usr/local/zend/etc/php.ini中的extension = php_pdo_mysql.dll
答案 0 :(得分:1)
确保安装了PHP MySQL扩展程序。在Ubuntu上将是:
sudo apt-get install php5-mysql
答案 1 :(得分:0)
我对这个PDO系有同样的问题,然后首先,我安装了Tim Fountain发布的php5-mysql包。第二步是从线上移除逃脱。
'driver_options' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"
),
在两件事之后,它都有效!