Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Can't Run Migration
  • Hey Everyone,

       I have been learning how to use FuelPHP for a couple weeks now and have been able to run migrations fine when using mamp but I have recently moved over to FortRabbit and after getting everything setup I get the following errors when running oil r migrate

    Uncaught exception PDOException: SQLSTATE[HY000] [2002] Operation timed out
    #0 /Users/tjnine/PhpstormProjects/Octane/fuel/core/classes/database/pdo/connection.php(96): PDO->__construct('mysql:host=octa...', 'octane', 'SeECgnSkmFDpbMA...', Array)
    #1 /Users/tjnine/PhpstormProjects/Octane/fuel/core/classes/database/pdo/connection.php(191): Fuel\Core\Database_PDO_Connection->connect()
    #2 /Users/tjnine/PhpstormProjects/Octane/fuel/core/classes/database/query.php(287): Fuel\Core\Database_PDO_Connection->query(1, 'SELECT * FROM `...', false)
    #3 /Users/tjnine/PhpstormProjects/Octane/fuel/core/classes/dbutil.php(621): Fuel\Core\Database_Query->execute(NULL)
    #4 /Users/tjnine/PhpstormProjects/Octane/fuel/core/classes/migrate.php(595): Fuel\Core\DBUtil::table_exists('migration')
    #5 /Users/tjnine/PhpstormProjects/Octane/fuel/core/classes/migrate.php(74): Fuel\Core\Migrate::table_version_check()
    #6 [internal function]: Fuel\Core\Migrate::_init()
    #7 /Users/tjnine/PhpstormProjects/Octane/fuel/core/classes/autoloader.php(375): call_user_func('Migrate::_init')
    #8 /Users/tjnine/PhpstormProjects/Octane/fuel/core/classes/autoloader.php(249): Fuel\Core\Autoloader::init_class('Migrate')
    #9 [internal function]: Fuel\Core\Autoloader::load('Migrate')
    #10 /Users/tjnine/PhpstormProjects/Octane/fuel/core/tasks/migrate.php(223): spl_autoload_call('Migrate')
    #11 /Users/tjnine/PhpstormProjects/Octane/fuel/core/tasks/migrate.php(151): Fuel\Tasks\Migrate::_run('default', 'app')
    #12 /Users/tjnine/PhpstormProjects/Octane/fuel/core/base.php(457): Fuel\Tasks\Migrate->__call('run', Array)
    #13 /Users/tjnine/PhpstormProjects/Octane/fuel/core/base.php(457): Fuel\Tasks\Migrate->run()
    #14 /Users/tjnine/PhpstormProjects/Octane/fuel/packages/oil/classes/refine.php(108): call_fuel_func_array(Array, Array)
    #15 [internal function]: Oil\Refine::run('migrate', Array)
    #16 /Users/tjnine/PhpstormProjects/Octane/fuel/packages/oil/classes/command.php(126): call_user_func('Oil\Refine::run', 'migrate', Array)
    #17 /Users/tjnine/PhpstormProjects/Octane/oil(61): Oil\Command::init(Array)
    #18 {main}

    for some I reason I can't connect, I have tried using every host I know of, and I can't set any permissions(mySQL Workbench).....can someone please help?
  • It's probably a question you have to ask FortRabbit.

    It just means your PDO driver can not connect to the database. If the database is on the local machine, it could be that it looks for the socket file in the wrong location, with something like:

    'dsn' => 'mysql:unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock;dbname=MY_DB_NAME'.
  • Ok I will investigate that then...

    Yeah, it's confusing the heck out of me because mySQL Workbench connects to the DB just fine!? I submitted a support message before I posted on here so hopefully I won't have to wait to long for an answer. Thanks for your help.
  • This is what I get....


    PDO Driver for MySQL => enabled
    Client API version => mysqlnd 5.0.10 - 20111026 - $Id: 2d8f599f49e5e8d2f5ba7112b5c444b3e2e48cdf $

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

    That looks right to me. Do you think if I tried to run oil commands in a production environment they would work?
  • I don't know if that is right? Is the socket file really there?

    The only difference in environments is the config that is used, so that shouldn't matter.
  • No it's not there, so I need to install mysql?
  • I just tested on my virtual host and I get the same errors as using FortRabbit? I'm so close to saying screw this, it's been 2 days and I still can't get this to work. I love this framework so much which makes this even more frustrating.
  • I haven't got a clue what exactly you are doing.

    I don't know if you need to install mysql, I don't know what FortRabbit is and what they supply.

    In case you work locally, it depends on what you use. One of the common problems in environments like WAMP and MAMP is that they haven't taken the commandline into account, and the php config is in a non-standard place. Which means that php-cli (which is used by oil) doesn't have to correct php.ini settings, which in turn can cause database connection problems.

    What are you using to run your virtual host? Because I have never seen this issue, both with a local MySQL and a remote MySQL.

    Same is probably true for container based hosting providers.
  • If you can't get it, if you want you can zip your entire virtualhost, and send it to me at wanwizard<at>, and I'll have a look here.

    If it runs here, it's not the framework or your code, it's your setup.
  • that would be so great of you! It won't even run on Mamp anymore and I am doing the same setup every time. I put the unzipped files where I want them, and cd into the directory run composer update and change all the configs, and nothing....I tested some other apps that use PDO and they connect fine on the virtual host, I didn't bother with FortRabbit(cloud hosting). Thanks for your time on this one Harro, I really really appreciate man. I just spent like $70 bus on FuelPHP books, video lessons, and the hosting. I have worked with a couple other frameworks, even Laravel 4 but I like using this one the most and now that you can control all packages with composer is a bonus.
  • Thanks, received and installed.

    Apart from the fact that your config didn't autoload the Orm package (so your article controller gave a fatal error), everything runs fine here. I ran the migration using oil to create the articles table, and after that no problem with the controller.

    So, good news is that there's nothing wrong with the framework, and there's nothing wrong with your code.

    Bad news is that we still don't know what the problem is.

    If you're on a Mac, you can also try to replace "localhost" by "" in your db config. Some setups don't like "localhost", as it is actually an illegal hostname according to the RFC.
  • I got everything working now. Thanks for your help. I really appreciate it.
  • Can you explain for other readers what exactly the problem was, and how you fixed it?
  • I've same problem how I can fix that?
    I work windows
    C:\Program Files (x86)\VertrigoServ\www\fuelphp>php oil refine migrate Uncaught exception Fuel\Core\Database_Exception: could not find driver Callstack: #0 C:\Program Files (x86)\VertrigoServ\www\fuelphp\fuel\core\classes\database\pdo\connection.php(191): Fuel\Core\Database_PDO_Con nection->connect() #1 C:\Program Files (x86)\VertrigoServ\www\fuelphp\fuel\core\classes\database\query.php(287): Fuel\Core\Database_PDO_Connection-> query(1, 'SELECT * FROM `...', false) #2 C:\Program Files (x86)\VertrigoServ\www\fuelphp\fuel\core\classes\dbutil.php(621): Fuel\Core\Database_Query->execute(NULL) #3 C:\Program Files (x86)\VertrigoServ\www\fuelphp\fuel\core\classes\migrate.php(595): Fuel\Core\DBUtil::table_exists('migration' ) #4 C:\Program Files (x86)\VertrigoServ\www\fuelphp\fuel\core\classes\
  • It sounds like you need to install the PDO driver. What is your dev seup and what does it say when you look at your PHP info?
  • @joeymetal, please don't post the same question multiple times...
  • Sorry Harro I didn't see your post till just now. I started to fidget with my apache and virtual hosts files which wasn't allowing me to use localhost with my PDO connection(localhost:3306 or 127..0.0.1:3306) so I completely wiped out my computer and installed mavericks again because I wanted there to be no issues whatsoever. After I re-installed mavericks my config files went back to normal and my ssh tunnel started to connect but it wouldn't read mySQL. I changed the database config in Fuel to 'persistent' => false and everything worked fine after that.
  • Ok, thanks.

Howdy, Stranger!

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

In this Discussion