From d3b39d9d1e9868e39ff5cc8a6d5cd435fd6fe925 Mon Sep 17 00:00:00 2001 From: cbornhoft Date: Tue, 30 Oct 2018 07:51:19 -0400 Subject: [PATCH] Add executeWithoutId() method for inserts into tables without a primary key --- src/Queries/Insert.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Queries/Insert.php b/src/Queries/Insert.php index 23d8165..ff0b302 100644 --- a/src/Queries/Insert.php +++ b/src/Queries/Insert.php @@ -116,11 +116,12 @@ public function onDuplicateKeyUpdate($values) * * @throws Exception * - * @return integer last inserted id or false + * @return int|bool - Last inserted primary key */ public function execute($sequence = null) { $result = parent::execute(); + if ($result) { return $this->fluent->getPdo()->lastInsertId($sequence); } @@ -128,6 +129,24 @@ public function execute($sequence = null) return false; } + /** + * @param null $sequence + * + * @throws Exception + * + * @return bool + */ + public function executeWithoutId($sequence = null) + { + $result = parent::execute(); + + if ($result) { + return true; + } + + return false; + } + /** * @return string */