问题
I have xampp installed and want to get FuelPHP working. Everything seems to work fine, I scaffolded some stuff, that I want to migrate. But I get the error
Error - invalid data source name in COREPATH/classes/database/pdo/connection.php on line 94
My db.php looks like this:
return array(
'default' => array(
'type' => 'pdo',
'connection' => array(
'dsn' => 'mysql:host=127.0.0.1;dbname=pfpg',
'username' => 'root',
'password' => '',
'persistent' => false,
'compress' => false,
),
),
);
I tried it without the 'persistent' and 'compress' before, didn't work. Database name is correct, username too. I also tried it with 'mysql:host=localhost'. I don't get what I did wrong...
If you need more information, ask away!
回答1:
I configured the wrong db.php file, I didn't know, there was more than one. fuel/app/config/development/db.php was the right file, so it depends on the environment
回答2:
For those of you who none of this worked make sure of two things
- there are multiple db.php files
/fuel/app/config/development/db.php
. check environment as @user1978654 mentioned and double check the username and password is correct - Make sure
/var/mysql/mysql.sock
exists. In my case I was using/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
so i needed to create a symlink. Followed the instructions here
Hope that helps someone
回答3:
Go to fuel/app/config/development/db.php put your database name there .. and make sure you un comment the ORM package in fuel\app\config\config.php
来源:https://stackoverflow.com/questions/16121120/fuelphp-oil-migration-not-working