[英]Can't connect to database with Mysql
I have started learn Symfony. 我已经开始学习Symfony。 After reading the documentation of Symfony I wanted to try make my application.
阅读完Symfony的文档后,我想尝试制作我的应用程序。 I have already created a mysql database with the some data, but I can't connect to it within doctrine.
我已经用一些数据创建了一个mysql数据库,但是在学说中我无法连接到它。 As i read in the documentation, if i want to import my database into orm, i have to execute this commands:
正如我在文档中阅读的那样,如果要将数据库导入到orm中,则必须执行以下命令:
php app/console doctrine:mapping:import TestBundle yml
php app/console doctrine:generate:entities TestBundle
But i got message 但是我收到消息
[Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException]
[Symfony的\\元器件\\调试\\异常\\ UndefinedFunctionException]
Attempted to call function "mysqli_init" from namespace "Doctrine\\DBAL\\Driver\\Mysqli".尝试从命名空间“ Doctrine \\ DBAL \\ Driver \\ Mysqli”中调用函数“ mysqli_init”。
I successfully use mysqli in my flat-php application, but can't use in doctrine. 我已在我的Flat-PHP应用程序中成功使用mysqli,但不能在原则上使用。 Also the data for database connection is correct.
另外,用于数据库连接的数据是正确的。 Any ideas?
有任何想法吗?
I propose you to use slightly different configuration: 我建议您使用略有不同的配置:
// app/config/config.yml
imports:
- { resource: parameters.yml }
... // another configuration here
doctrine:
dbal:
driver: "%database_driver%"
and set your database driver to pdo_mysql : 并将数据库驱动程序设置为pdo_mysql :
// src/config/parameters.yml
parameters:
database_driver: pdo_mysql
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.