From ea88a51e66d90c59cfd2734f7b3a28efde79a317 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sat, 5 Oct 2013 20:00:15 +0200 Subject: [PATCH] Also insert the Id when using UUIDs or other pre-specified IDs for new rows --- class.databaserecord.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/class.databaserecord.php b/class.databaserecord.php index 8166dd0..94ac501 100644 --- a/class.databaserecord.php +++ b/class.databaserecord.php @@ -512,6 +512,14 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass if($insert_mode == CPHP_INSERTMODE_INSERT) { + if(!empty($this->uId)) + { + $sIdentifier = ":{$this->id_field}"; + $sKeyList[] = "`{$this->id_field}`"; + $sKeyIdentifierList[] = $sIdentifier; + $uValueList[$sIdentifier] = $this->uId; + } + $sQueryKeys = implode(", ", $sKeyList); $sQueryKeyIdentifiers = implode(", ", $sKeyIdentifierList); $query = "INSERT INTO {$this->table_name} ({$sQueryKeys}) VALUES ({$sQueryKeyIdentifiers})";