Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Help me with db connection
  • If I use 'type' => 'mysqli'
    what do I have to write in 'dsn' option
    'mysql:...' or 'mysqli:...'?

    Seemed both are not working...

  • [code]
    <?php
    /**
     * The development database settings. These get merged with the global settings.
     */

    return array(
    'default' => array(
    'connection'  => array(
    'dsn'        => 'mysql:host=localhost;dbname=yourdtabase',
    'username'   => 'root',
    'password'   => 'password',
    ),
    ),
    );
    [/code]
  • No, there is no 'type' => 'msqli'! Try to add it.
  • It has one solution - not use 'dsn' option, and use 'hostname' and 'database' instead.


  • HarroHarro
    Accepted Answer
    dsn is used with a PDO config, so with 'type' => 'pdo'.

    The other types, 'mysql' and 'mysqli' don't use the DSN, they use individual values:

        /**
         * Base PDO config
         */
        'default' => array(
            'type'        => 'pdo',
            'connection'  => array(
                'dsn'   => '',
                'username'   => '',
                'password'   => '',
                'persistent' => false,
                'compress'   => false,
            ),
            'identifier'   => '`',
            'table_prefix' => '',
            'charset'      => 'utf8',
            'collation'    => false,
            'enable_cache' => true,
            'profiling'    => false,
            'readonly'     => false,
        ),

        /**
         * Base MySQLi config
         *

        'default' => array(
            'type'        => 'mysqli',
            'connection'  => array(
                'hostname'   => '',
                'username'   => '',
                'password'   => '',
                'database'   => '',
                'persistent' => false,
            ),
            'identifier'   => '`',
            'table_prefix' => '',
            'charset'      => 'utf8',
            'collation'    => false,
            'enable_cache' => true,
            'profiling'    => false,
            'readonly'     => false,
        ),

Howdy, Stranger!

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

In this Discussion