Added cache purging post-execution for multiple row UPDATEs
This commit is contained in:
parent
50664a22ac
commit
3290ee0135
2 changed files with 36 additions and 2 deletions
19
jar.php
19
jar.php
|
@ -5185,6 +5185,9 @@ class Model extends Object
|
|||
// Multiple row query / queries
|
||||
if ($this->commit_type == 'queue')
|
||||
{
|
||||
$update = false;
|
||||
$cache_keys = array();
|
||||
|
||||
/**
|
||||
* @todo I outta loop through twice to determine if it's an INSERT
|
||||
* or an UPDATE. As it stands, you could run into a scenario where
|
||||
|
@ -5197,6 +5200,8 @@ class Model extends Object
|
|||
// Performs an UPDATE with multiple queries
|
||||
if (array_key_exists($this->columns['id'], $record))
|
||||
{
|
||||
$update = true;
|
||||
|
||||
if (!isset($sql))
|
||||
{
|
||||
$sql = '';
|
||||
|
@ -5212,6 +5217,10 @@ class Model extends Object
|
|||
$update_fields[] = $field . ' = ?';
|
||||
$input_parameters[] = (is_array($value) ? (JSON_AVAILABLE ? json_encode($value) : serialize($value)) : $value);
|
||||
}
|
||||
else
|
||||
{
|
||||
$cache_keys[] = $this->model . '-' . $value;
|
||||
}
|
||||
}
|
||||
|
||||
// @todo Check if the column was passed in
|
||||
|
@ -5304,7 +5313,15 @@ class Model extends Object
|
|||
}
|
||||
}
|
||||
|
||||
return $this->db->execute($sql . ';', $input_parameters);
|
||||
$results = $this->db->execute($sql . ';', $input_parameters);
|
||||
|
||||
// Clears the cache
|
||||
if ($update && $this->use_cache)
|
||||
{
|
||||
$this->cache->delete($cache_keys);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
// Single row INSERT or UPDATE
|
||||
elseif (count($this->record) > 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue