From 6498132ef231e8a8fd75f8dad8e330404693686f Mon Sep 17 00:00:00 2001 From: Pierre Date: Sat, 10 Jun 2017 14:49:51 +0200 Subject: [PATCH] Added a getLastInsertedID method --- classes/DBLibrary.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/classes/DBLibrary.php b/classes/DBLibrary.php index a0ea86a..0f7c54a 100755 --- a/classes/DBLibrary.php +++ b/classes/DBLibrary.php @@ -311,6 +311,25 @@ class DBLibrary { return $return; } + /** + * Get the last inserted ID of a cursor + * + * @param Nothing + * @return Integer The last inserted ID (0 for a failure) + */ + public function getLastInsertedID(){ + try { + //Get & return last inserted ID + return $this->db->lastInsertId(); + } + catch(Exception $e){ + exit($this->echoException($e)); + } + catch(PDOException $e){ + exit($this->echoPDOException($e)); + } + } + /** * Get datas from a table *