Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
can't use php oil refine migrate
  • Hi
    i can't use the php oil r migrate .
    i os : mac-lion;
    i use the mamp pro
    and i hostname : local host
    i dbname : alphadata
    i os acount : farzad

    Farzads-Mac-Pro:alphadata farzad$ php oil refine migrate
    Uncaught exception Fuel\Core\Database_Exception: No MySQLi Connection
    Callstack:
    #0 /Users/farzad/Sites/alphadata/fuel/core/classes/database/mysqli/connection.php(216): Fuel\Core\Database_MySQLi_Connection->connect()
    #1 /Users/farzad/Sites/alphadata/fuel/core/classes/database/query.php(287): Fuel\Core\Database_MySQLi_Connection->query(1, 'SELECT * FROM `...', false)
    #2 /Users/farzad/Sites/alphadata/fuel/core/classes/dbutil.php(621): Fuel\Core\Database_Query->execute(NULL)
    #3 /Users/farzad/Sites/alphadata/fuel/core/classes/migrate.php(595): Fuel\Core\DBUtil::table_exists('migration')
    #4 /Users/farzad/Sites/alphadata/fuel/core/classes/migrate.php(74): Fuel\Core\Migrate::table_version_check()
    #5 [internal function]: Fuel\Core\Migrate::_init()
    #6 /Users/farzad/Sites/alphadata/fuel/core/classes/autoloader.php(364): call_user_func('Migrate::_init')
    #7 /Users/farzad/Sites/alphadata/fuel/core/classes/autoloader.php(247): Fuel\Core\Autoloader::init_class('Migrate')
    #8 [internal function]: Fuel\Core\Autoloader::load('Migrate')
    #9 /Users/farzad/Sites/alphadata/fuel/core/tasks/migrate.php(223): spl_autoload_call('Migrate')
    #10 /Users/farzad/Sites/alphadata/fuel/core/tasks/migrate.php(151): Fuel\Tasks\Migrate::_run('default', 'app')
    #11 /Users/farzad/Sites/alphadata/fuel/core/base.php(434): Fuel\Tasks\Migrate->__call('run', Array)
    #12 /Users/farzad/Sites/alphadata/fuel/core/base.php(434): Fuel\Tasks\Migrate->run()
    #13 /Users/farzad/Sites/alphadata/fuel/packages/oil/classes/refine.php(106): call_fuel_func_array(Array, Array)
    #14 [internal function]: Oil\Refine::run('migrate', Array)
    #15 /Users/farzad/Sites/alphadata/fuel/packages/oil/classes/command.php(125): call_user_func('Oil\Refine::run', 'migrate', Array)
    #16 /Users/farzad/Sites/alphadata/oil(57): Oil\Command::init(Array)
    #17 {main}
    And I can not even say that I'm connected through a terminal database.
  • HarroHarro
    Accepted Answer
    It's a common problem on a Mac, with MAMP, but also with other packaged environments.

    The problem is that php in MAMP uses a non-standard php.ini location, so php-cli (used by oil) which uses the default in /etc will use the wrong one. Result of this is that for example the extensions and modules aren't loaded so you miss all database connectivity.

    Quickest solution is to find which php.ini is used by MAMP, and change /etc/php.ini so that it is a symlink to that file, to ensure both use the same ini file.

    Once done, the next issue you can run into is in the docs: http://docs.fuelphp.com/installation/troubleshooting.html#oil_db_error
  • i could not understand the your solution  .
    Can you explain exactly what do I do?
  • so
    error after changes
    Uncaught exception Fuel\Core\Database_Exception: No database selected [ 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; ]
    Callstack:
    #0 /Users/farzad/Sites/alphadata/fuel/core/classes/database/query.php(287): Fuel\Core\Database_MySQLi_Connection->query(2, 'CREATE TABLE IF...', false)
    #1 /Users/farzad/Sites/alphadata/fuel/core/classes/dbutil.php(135): Fuel\Core\Database_Query->execute(NULL)
    #2 /Users/farzad/Sites/alphadata/fuel/core/classes/migrate.php(598): Fuel\Core\DBUtil::create_table('migration', Array)
    #3 /Users/farzad/Sites/alphadata/fuel/core/classes/migrate.php(74): Fuel\Core\Migrate::table_version_check()
    #4 [internal function]: Fuel\Core\Migrate::_init()
    #5 /Users/farzad/Sites/alphadata/fuel/core/classes/autoloader.php(364): call_user_func('Migrate::_init')
    #6 /Users/farzad/Sites/alphadata/fuel/core/classes/autoloader.php(247): Fuel\Core\Autoloader::init_class('Migrate')
    #7 [internal function]: Fuel\Core\Autoloader::load('Migrate')
    #8 /Users/farzad/Sites/alphadata/fuel/core/tasks/migrate.php(223): spl_autoload_call('Migrate')
    #9 /Users/farzad/Sites/alphadata/fuel/core/tasks/migrate.php(151): Fuel\Tasks\Migrate::_run('default', 'app')
    #10 /Users/farzad/Sites/alphadata/fuel/core/base.php(434): Fuel\Tasks\Migrate->__call('run', Array)
    #11 /Users/farzad/Sites/alphadata/fuel/core/base.php(434): Fuel\Tasks\Migrate->run()
    #12 /Users/farzad/Sites/alphadata/fuel/packages/oil/classes/refine.php(106): call_fuel_func_array(Array, Array)
    #13 [internal function]: Oil\Refine::run('migrate', Array)
    #14 /Users/farzad/Sites/alphadata/fuel/packages/oil/classes/command.php(125): call_user_func('Oil\Refine::run', 'migrate', Array)
    #15 /Users/farzad/Sites/alphadata/oil(57): Oil\Command::init(Array)
    #16 {main}

  • HarroHarro
    Accepted Answer
    Is your app/config/development/db.php config file configured correctly? It looks like the database name is missing from it?
  • this is app/config/development/db.php
    <?php
    /**
     * The development database settings. These get merged with the global settings.
     */

    return array(
        'default' => array(
            'connection'  => array(
                'dsn'        => 'mysql:host=localhost;dbname=alphadata',
                'username'   => 'root',
                'password'   => 'root',
            ),
        ),
    );

  • HarroHarro
    Accepted Answer
    On a Mac, using localhost is not a good idea, either use a proper host name, or use 127.0.0.1.
    And that database exists?
  • HarroHarro
    Accepted Answer
    Also, since you don't define the driver type in this db.php, what is defined in the global config (in app/config/db.php) ?

    Does your website itself work? Does your index.php load. If so, could you add

    \Config::load('db', true);
    var_dump(\Config::get('db.default'));
    die();

    to your default controller's action_index, and post the result here?
  • thank u
    My problem was solved.
    The problem was fuel/core/config/db.php file.

    and php version .
    thank u mr Harro .
  • HarroHarro
    Accepted Answer
    Cool. Good luck, and happy coding!
  • Thank you sir. I was so glad to meet you.
    :*

Howdy, Stranger!

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

In this Discussion