Added support for "REPLACE" SQL syntax.

This commit is contained in:
Josh Sherman 2011-07-31 18:33:17 -04:00
parent c6bda10e3f
commit 3ea9ec8f36
2 changed files with 32 additions and 2 deletions

View file

@ -66,6 +66,14 @@ class Model extends Object
*/
protected $delayed = false;
/**
* Replace instead of Insert/Update?
*
* @access protected
* @var boolean
*/
protected $replace = false;
/**
* Field List
*
@ -866,7 +874,14 @@ class Model extends Object
$update = (isset($this->record[$this->id]) && trim($this->record[$this->id]) != '');
// Establishes the query, optionally uses DELAYED INSERTS
$sql = ($update === true ? 'UPDATE' : 'INSERT' . ($this->delayed == true ? ' DELAYED' : '') . ' INTO') . ' ' . $this->table . ' SET ';
if ($this->replace === true)
{
$sql = 'REPLACE' . ($this->delayed == true ? ' DELAYED' : '') . ' INTO ' . $this->table . ' SET ';
}
else
{
$sql = ($update === true ? 'UPDATE' : 'INSERT' . ($this->delayed == true ? ' DELAYED' : '') . ' INTO') . ' ' . $this->table . ' SET ';
}
$input_parameters = null;
// Limits the columns being updated