PHP 5.4.9未定义的类常量';MYSQL_ATTR_INIT_命令';
我试图通过以下教程和运行该命令来配置条令: ./vendor/bin/doctrine模块orm:validate schema I出现错误: 第19行var/www/CommunicationApp/config/autoload/global.php中未定义的类常量“MYSQL\u ATTR\u INIT\u COMMAND” 以下是global.php文件:PHP 5.4.9未定义的类常量';MYSQL_ATTR_INIT_命令';,php,mysql,zend-framework,doctrine-orm,zend-framework2,Php,Mysql,Zend Framework,Doctrine Orm,Zend Framework2,我试图通过以下教程和运行该命令来配置条令: ./vendor/bin/doctrine模块orm:validate schema I出现错误: 第19行var/www/CommunicationApp/config/autoload/global.php中未定义的类常量“MYSQL\u ATTR\u INIT\u COMMAND” 以下是global.php文件: <?php /** * Global Configuration Override * * You can use th
<?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',
),
),
);
确保安装了PHP MySQL扩展。在Ubuntu上,这将是:
sudo apt-get install php5-mysql
我在这个PDO行中遇到了同样的问题,然后首先,我安装了Tim Fountain发布的php5 mysql包。第二步是从线路上移除逃生通道
'driver_options' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"
),
在这两件事之后,它成功了 尝试将其命名为“根”命名空间:\PDO::MYSQL_ATTR_INIT_COMMAND
(PDO之前的反斜杠)它不起作用,相同的错误检查此答案:现在我遇到此错误:[doctor\Common\Persistence\Mapping\MappingException]文件映射驱动程序必须具有有效的目录路径,但是,给定的路径[/var/www/CommunicationApp/module/CsnFileManager/config/。/src/CsnFileMa-manager/Entity]似乎不正确!