Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Catch non-existent database
  • How would one check whether the currently configured database exists?
    I need to handle that exception in my app before any DB methods are called. Specifically, I'm trying to prevent the user from getting Fuel's 1049 exception:
    Fuel\Core\Database_Exception [ 1049 ]: Unknown database 'foo'
  • Put something like this at a point where you are sure there's no queries ran earlier:
    try
    {
        \Database_Connection::instance()->connect(); // put your db connection name in instance($name) if you want a non-default connection group
    }
    catch (\Database_Exception $e)
    {
        // do something when connecting failed
    }
    
  • Thanks again, Jelmer. Fuel's support is top-notch

Howdy, Stranger!

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

In this Discussion