php:fuelphp:database_setting

データベースの接続設定と O/R マッパーの有効化

  1. development の接続設定を行う。
    fuelapp/fuel/app/config/development/db.php
    <?php
    /**
     * The development database settings.
     */
     
    return array(
        'default' => array(
            'connection'  => array(
                //'dsn'        => 'mysql:host=localhost;dbname=fuel_db',
                'hostname'   => 'localhost',
                'database'   => 'fuel_db',
                'username'   => 'fuel_app',
                'password'   => 'password',
            ),
        ),
    );
  2. production の接続設定を行う。
    fuelapp/fuel/app/config/production/db.php
    <?php
    /**
     * The production database settings.
     */
     
    return array(
        'default' => array(
            'connection'  => array(
                //'dsn'        => 'mysql:host=localhost;dbname=fuel_db',
                'hostname'   => 'localhost',
                'database'   => 'fuel_db',
                'username'   => 'fuel_app',
                'password'   => 'password',
            ),
        ),
    );
  3. ベースのデータベース設定を行う。
    <?php
    /**
     * 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',
            'type'        => 'mysqli',
            'connection'  => array(
                'persistent' => false,
            ),
            'identifier'   => '`',
            'table_prefix' => '',
            'charset'      => 'utf8',
            'enable_cache' => true,
            'profiling'    => false,
        ),
     
        'redis' => array(
            'default' => array(
                'hostname'  => '127.0.0.1',
                'port'      => 6379,
                'timeout'    => null,
            )
        ),
     
    );
  4. O/R マッパーを有効化する。
    fuel/app/config/config.php
    'packages'  => array(
        'orm', // Ormを有効化
    ),
  • php/fuelphp/database_setting.txt
  • 最終更新: 2019/08/19 07:04
  • by ともやん