Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Uncaught exception PDOException: SQLSTATE[55000]
  • I have Postgresql 9.5
    When you try to migrate

    Uncaught exception PDOException: SQLSTATE[55000]: Object not in prerequisite state: 7 ERROR:  lastval is not yet defined in this session
    #0 /var/www/fuel/core/classes/database/pdo/connection.php(307): PDO->lastInsertId()
    #1 /var/www/fuel/core/classes/database/query.php(314): Fuel\Core\Database_PDO_Connection->query(2, 'INSERT INTO "mi...', false)
    #2 /var/www/fuel/core/classes/migrate.php(350): Fuel\Core\Database_Query->execute(Object(Fuel\Core\Database_PDO_Connection))
    #3 /var/www/fuel/core/classes/migrate.php(323): Fuel\Core\Migrate::write_install('default', 'app', '032_create_chec...')
    #4 /var/www/fuel/core/classes/migrate.php(144): Fuel\Core\Migrate::run(Array, 'default', 'app', 'up')
    #5 /var/www/fuel/core/classes/migrate.php(168): Fuel\Core\Migrate::version(NULL, 'default', 'app', false)
    #6 /var/www/fuel/core/tasks/migrate.php(283): Fuel\Core\Migrate::latest('default', 'app', false)
    #7 /var/www/fuel/core/tasks/migrate.php(197): Fuel\Tasks\Migrate::_run('default', 'app')
    #8 /var/www/fuel/core/base56.php(37): Fuel\Tasks\Migrate->__call('_run', Array)
    #9 /var/www/fuel/packages/oil/classes/refine.php(108): call_fuel_func_array(Array, Array)
    #10 [internal function]: Oil\Refine::run('\\Fuel\\Tasks\\Mig...', Array)
    #11 /var/www/fuel/packages/oil/classes/command.php(126): call_user_func('Oil\\Refine::run', 'migrate', Array)
    #12 /var/www/oil(68): Oil\Command::init(Array)
    #13 {main}
  • HarroHarro
    Accepted Answer
    This is a known problem, there is no specific PostgreSQL database driver at the moment.

    The database drivers are required to return the generated id in case of an auto increment primary key column, or return null otherwise. But in case of the PGSQL driver, it throws an exception is no sequence name has been passed.

    As a workaround, change /var/www/fuel/core/classes/database/pdo/connection.php#307 if you are using the ORM to

    // Return a list of insert id and rows created
    return array(
    catch (\PDOException $e)
    return array(

    or if you don't use the ORM, simply to

    return array(

    We're working on a rewrite of the database drivers to address this (and other) issues for the next release.
  • I solved the problem by replacing library files. The "correct" library for PHP7 I put in public
  • Shouldn't that be fixed by PHP itself? Or is it just that your PHP distro has the wrong version?

Howdy, Stranger!

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

In this Discussion