Added inc/decrement functionality to the Model
Sure beats incrementing the variable then setting it! Usage: $model->record['column'] = '++'; // or '--'. Only works with single row updates at the moment. May expand into allowing a variable step to be defined (+10 or ++10 or something... I say that cause I think the double character is a bit safer since you could in theory set a value to -10000 and not want it to decrement by 10k)
This commit is contained in:
parent
c19ac9fbae
commit
fe0fd407cf
2 changed files with 22 additions and 2 deletions
|
@ -1301,7 +1301,17 @@ class Model extends Object
|
|||
$sql .= ', ';
|
||||
}
|
||||
|
||||
$sql .= $column . ' = ?';
|
||||
$sql .= $column . ' = ';
|
||||
|
||||
if (in_array($value, array('++', '--')))
|
||||
{
|
||||
$sql .= $column . ' ' . substr($value, 0, 1) . ' ?';
|
||||
$value = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql .= '?';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue