Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Error - invalid data source name in COREPATH/classes/database/pdo/connection.php on line 94
  • On Linux I installed fuel and oil and things seem to work.
    I can create models, controllers, etc using oil. the only issue at the moment is the migrations.

    When I run:  $ oil r migrate
    I get the error:
    Error - invalid data source name in COREPATH/classes/database/pdo/connection.php on line 94


    $ oil -v
    Fuel: 1.5 running in "development" mode



    PDO is enabled.....
    PDO

    PDO support => enabled
    ____________________________________________
    PDO drivers => mysql, sqlite, sqlite2

    pdo_mysql

    PDO Driver for MySQL => enabled
    Client API version => 5.5.21

    Directive => Local Value => Master Value
    pdo_mysql.default_socket => /var/lib/mysql/mysql.sock => /var/lib/mysql/mysql.sock




    Fuel->App->Config->migration.php
    ____________________________________________

    return array(
        'folder'         => 'migrations/',

        'connection'     => array(
            'dsn'            => 'mysql:host=localhost;dbname=db_name',
            'username'       => 'user_name',
            'password'       => 'password'
        ),

        'table'            => 'migration'
    );

    /////////// I did create the migration table in the db, but it only has noe col 'id'
     I had tried this before creating the table and was getting the same error.  Is the 'migration' table automatically created, or do i have to create it, and if so, what's the structure?


    Fuel->App->Config->db.php
    ____________________________________________
    return array(
        // a PDO driver configuration, using MySQL
        // possible 'default' , 'development'
        'default' => array(
            'type'           => 'pdo',
            'connection'     => array(
                'dsn'            => 'mysql:host=localhost;dbname=db_name',
                'username'       => 'user_name',
                'password'       => 'password',
                'persistent'     => false,
                'compress'       => false,
            ),
            'identifier'   => '"',
            'table_prefix'   => '',
            'charset'        => 'utf8',
            'enable_cache'   => true,
            'profiling'      => false,
        ),
    );




    Migrations Dir:  Fuel->App->Migrations
    ____________________________________________


    Any suggestions as to what is going on?
    Thanks.


  • I hope your directory names are lower case, otherwise Fuel can't find anything.

    Your db config should be in app/config/development/db.php, as db config is specified per environment. Only global settings go in app/config/db.php.

    Both files are merged upon load, so now the default db config that is still present in the development db.php file is overwriting your global config...
  • Nice.
    That was it. I had not set the db.in dev.

    But now i get this:
    42000 - SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"migration" (
            "type" varchar(25) NOT NULL,
            "name" varchar(50) NOT NULL,
            "migr' at line 1 with query: "CREATE TABLE IF NOT EXISTS "migration" (
            "type" varchar(25) NOT NULL,
            "name" varchar(50) NOT NULL,
            "migration" varchar(100) DEFAULT '' NOT NULL
    ) DEFAULT CHARACTER SET utf8;" in COREPATH/classes/database/pdo/connection.php on line 175

    (and yes, dirs are all lc)
  • In your config, you have

    'identifier'   => '"',

    For MySQL, the identifier is a ` (a backtick).
  • Geeze. Two easy things. Sorry I missed them. My IDE auto folds comments and missed them in the db. files.

    Thanks for the help.

Howdy, Stranger!

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

In this Discussion