【问题标题】:Internal Server Error when executing basic SQL statement [duplicate]执行基本 SQL 语句时出现内部服务器错误 [重复]
【发布时间】: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.htmlpublic function indexAction() { $conn = $this->get('database_connection'); $users = $conn->fetchAll('SELECT * FROM users'); // ... }

标签: php database symfony


【解决方案1】:

似乎存在驱动程序问题。你需要确保你的 PHP 环境已经加载了pdo_mysql。如需更多信息,请参阅this post

【讨论】:

  • 它已经安装好了。这就是为什么我再次问这个问题。你提到的帖子不包括我的答案。
  • 您如何验证它是否已安装?仅仅在系统上是不够的——它必须在 php.ini 中配置。检查的一个好方法是运行 phpinfo() (php.net/phpinfo)。
  • 具体来说,当你运行 phpinfo() 时,它是否真的列出了 PDO 下的 MySQL 支持?可能你有一些基本的 PDO 库,但没有你需要的 MySQL 版本。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-02-27
  • 2012-08-14
  • 2020-12-18
  • 1970-01-01
相关资源
最近更新 更多