Phinx: how to get last inserted ID ?

Created on 12 Apr 2016  路  2Comments  路  Source: cakephp/phinx

hi, is there a way to get last inserted ID?

docs

Most helpful comment

Can you try $this->getAdapter()->getConnection()->lastInsertId();

The getConnection() method isn't in the AbstractInterface but is in the PDOAdapter which implements that interface. So, any PDO based connection should be able to use the above call.

All 2 comments

Can you try $this->getAdapter()->getConnection()->lastInsertId();

The getConnection() method isn't in the AbstractInterface but is in the PDOAdapter which implements that interface. So, any PDO based connection should be able to use the above call.

Please make a PR for docs to include this.

Was this page helpful?
0 / 5 - 0 ratings