Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
PDO exception
  • Hey everyone, I'm trying to use the PDO driver for enhanced security but cant query the database. I set the the static model properties but I always get the following exception regardless of what model i'm using. Fuel\Core\Database_Exception [ Error ]: invalid data source name. If I switch to mysqli there are no problems. Anyone else using the PDO driver and run into this?
  • The message to me is very clear: your DSN is wrong. So check your config/db.php and correct the error in the DSN.
  • The DSN variable is null when the connection is trying to be made on https://github.com/fuel/core/blob/master/classes/database/pdo/connection.php#L72
    I can enter the params manually like $this->_connection = new \PDO("mysql:host=localhost;dbname=fuel_dev", $username, $password, $attrs); and it will make a connection, but there is no explicit dsn param in the config/db.php file
  • You can just add the 'dsn' parameter to the config array, instead of hostname and port. I'm afraid the example is MySQL only, I'll add it to the docs.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion