【发布时间】:2014-03-11 23:41:34
【问题描述】:
我正在本地 wamp 服务器上工作并尝试从 phpMyAdmin 检索数据。但我遇到了一个错误。
找不到驱动程序 500 内部服务器错误 - PDOException
我的路由.yml
# This file is auto-generated during the composer install
parameters:
database_driver: pdo_mysql
database_host: www.example.com
database_port: null
database_name: mydb
database_user: myuser
database_password: mypass
mailer_transport: smtp
mailer_host: www.example.com
mailer_user: null
mailer_password: null
locale: en
secret: ThisTokenIsNotSoSecretChangeIt
database_path: null
我的控制器
$connection = $this->get("database_connection");
$statement = $connection->prepare("SELECT * FROM table");
$statement->execute();
$tabs = $statement->fetchAll();
【问题讨论】:
-
检查你的 php.ini 是否 pdo_mysql 没有注释
-
您是否尝试使用 Doctrine DBAL 连接? symfony.com/doc/current/cookbook/doctrine/dbal.html
public function indexAction() { $conn = $this->get('database_connection'); $users = $conn->fetchAll('SELECT * FROM users'); // ... }