Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Why am i having a hard time configuring the db.php?
  • I'm trying to connect to my db call blog_example but no luck so far!
    This is what i have done.\\ app/config/development/db.php return array(
    'default' => array(
    'connection' => array(
    'dsn' => 'mysql:host=localhost;dbname=blog_example',
    'username' => 'root',
    'password' => 'root',
    ),
    ),
    ); also /**
    * Base Database Config.
    *
    * See the individual environment DB configs for specific config information.
    */ return array(
    'active' => 'default', /**
    * Base config, just need to set the DSN, username and password in env. config.
    */
    'default' => array(
    'type' => 'pdo',
    'connection' => array(
    'hostname' => 'localhost',
    'database' => 'blog_example',
    'username' => 'root',
    'password' => 'root',
    'persistent' => false,
    ),
    'identifier' => '`',
    'table_prefix' => '',
    'charset' => 'utf8',
    'caching' => false,
    'profiling' => false,
    ), 'redis' => array(
    'default' => array(
    'hostname' => '127.0.0.1',
    'port' => 6379,
    )
    ), );
  • There is no need to modify the base config, it is merged with the environment config when used. So it should not contain any database, username or password, only some default values. Your development config looks ok, but as you haven't given any information, we can only guess what the issue is here. No PHP PDO driver installed? No PDO Mysql driver installed? Not using the development config but another environment? On a Mac that doesn't like "localhost" in the config? ...
  • I have a Mac and connect just fine.
    So I would agree that Environment or base config is causing a problem. I also had to change MAMP to PHP 5.3
  • Harro Verton wrote on Saturday 31st of March 2012:
    There is no need to modify the base config, it is merged with the environment config when used. So it should not contain any database, username or password, only some default values. Your development config looks ok, but as you haven't given any information, we can only guess what the issue is here. No PHP PDO driver installed? No PDO Mysql driver installed? Not using the development config but another environment? On a Mac that doesn't like "localhost" in the config? ...

    i have pdo driver install, also mysql, mysqli, i have work on prepare statemets in the past. The thing here is that no matter what a put into the development db can't get it to work. I just simply doesn't connect to the db. I wish this will be like CI where you just put localhost or 127.0.0.1 db name pass and done!
  • Here is my setup
    /**
     * The development database settings.
     */
    
    return array(
     'default' => array(
      'connection'  => array(
       'dsn'        => 'mysql:host=localhost;dbname=stationwagon',
       'username'   => 'root',
       'password'   => 'root',
      ),
     ),
    
    /**
     * Base Database Config.
     *
     * See the individual environment DB configs for specific config information.
     */
    
    return array(
     'active' => 'default',
    
     /**
      * Base config, just need to set the DSN, username and password in env. config.
      */
     'default' => array(
      'type'        => 'pdo',
      'connection'  => array(
       'persistent' => false,
      ),
      'identifier'   => '`',
      'table_prefix' => 'sw_',
      'charset'      => 'utf8',
      'caching'      => false,
      'profiling'    => false,
     ),
    
     'redis' => array(
      'default' => array(
       'hostname'  => '127.0.0.1',
       'port'      => 6379,
      )
     ),
    
    );
    
    
    /**
     * Your environment.  Can be set to any of the following:
     *
     * Fuel::DEVELOPMENT
     * Fuel::TEST
     * Fuel::STAGE
     * Fuel::PRODUCTION
     */
    Fuel::$env = (isset($_SERVER['FUEL_ENV']) ? $_SERVER['FUEL_ENV'] : Fuel::DEVELOPMENT);
    
  • david strada wrote on Sunday 1st of April 2012:
    I wish this will be like CI where you just put localhost or 127.0.0.1 db name pass and done!
    That is the same here, I can't remember how many Fuel installs I've rolled out the last year, and I never had issues. Having said that, I don't use a Mac, there's always something with them, and MAMP is high on the crap list. Other PHP apps in this same installation work fine? If your mysql socket file is not in the default place PHP expects it (which is probably the case on a Mac), you'll have to modify php.ini. Given the fact that you installed 5.3 manually, changes are that your php.ini doesn't contain a Mac specific config.

Howdy, Stranger!

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

In this Discussion