Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Solar_Sql_Model: [FIX] In method insert(), clear the cache *after* re…

…trieving the last insert ID. Thanks, Richard Thomas, for the patch.
  • Loading branch information...
commit b3f48ca93ef5df582ebdc26afcd8fcf29a9e889c 1 parent dd1314f
Paul M. Jones authored
Showing with 9 additions and 5 deletions.
  1. +9 −5 Solar/Sql/Model.php
View
14 Solar/Sql/Model.php
@@ -1570,10 +1570,7 @@ public function insert($data)
$this->_table_name,
$data
);
-
- // clear the cache for this model and related models
- $this->_cache->deleteAll();
-
+
// does the table have an autoincrement column?
$autoinc = null;
foreach ($this->_table_cols as $name => $info) {
@@ -1585,7 +1582,14 @@ public function insert($data)
// return the last insert id, or just "true" ?
if ($autoinc) {
- return $this->_sql->lastInsertId($this->_table_name, $autoinc);
+ $id = $this->_sql->lastInsertId($this->_table_name, $autoinc);
+ }
+
+ // clear the cache for this model and related models
+ $this->_cache->deleteAll();
+
+ if ($autoinc) {
+ return $id;
} else {
return true;
}
Please sign in to comment.
Something went wrong with that request. Please try again.