"extra where condition, eg. to check etag on writing"

This commit is contained in:
Ralf Becker 2008-04-26 07:49:01 +00:00
parent c906d34880
commit 163b795d45

View File

@ -422,9 +422,10 @@ class so_sql
* saves the content of data to the db
*
* @param array $keys if given $keys are copied to data before saveing => allows a save as
* @param string|array $extra_where=null extra where clause, eg. to check the etag, returns 'nothing_affected' if not affected rows
* @return int 0 on success and errno != 0 else
*/
function save($keys=null)
function save($keys=null,$extra_where=null)
{
if (is_array($keys) && count($keys)) $this->data_merge($keys);
@ -478,7 +479,7 @@ class so_sql
$data[] = $keys[$n];
}
}
$keys = '';
$keys = $extra_where;
foreach($this->db_key_cols as $db_col => $col)
{
$keys[$db_col] = $this->data[$col];
@ -499,7 +500,7 @@ class so_sql
}
$this->db2data();
return $this->db->Errno;
return $this->db->Errno ? $this->db->Errno : ($extra_where && !$this->db->affected_rows() ? true : 0);
}
/**