Commit b0d971fc authored by Alexander Butenko's avatar Alexander Butenko

Merge pull request #4 from screeper/master

Added update "column = !column"
parents bc5116f8 231fa1dc
...@@ -477,6 +477,10 @@ class MysqliDb ...@@ -477,6 +477,10 @@ class MysqliDb
} }
} }
break; break;
case '[N]':
if($val == null) $this->_query .= "!" . $column . ", ";
else $this->_query .= "!" . $val . ", ";
break;
default: default:
die ("Wrong operation"); die ("Wrong operation");
} }
...@@ -754,6 +758,14 @@ class MysqliDb ...@@ -754,6 +758,14 @@ class MysqliDb
return Array ("[I]" => "-" . (int)$num); return Array ("[I]" => "-" . (int)$num);
} }
/**
* Method generates change boolean function call
* @param string column name. null by default
*/
public function not ($col = null) {
return Array ("[N]" => (string)$col);
}
/** /**
* Method generates user defined function call * Method generates user defined function call
* @param string user function body * @param string user function body
......
...@@ -49,8 +49,10 @@ if($id) ...@@ -49,8 +49,10 @@ if($id)
$data = Array ( $data = Array (
'firstName' => 'Bobby', 'firstName' => 'Bobby',
'lastName' => 'Tables', 'lastName' => 'Tables',
'editCount' => $db->inc(2) 'editCount' => $db->inc(2),
// editCount = editCount + 2; // editCount = editCount + 2;
'editBoolean' => $db->not()
// editBoolean = !editBoolean;
); );
$db->where('id', 1); $db->where('id', 1);
if($db->update('users', $data)) echo 'successfully updated'; if($db->update('users', $data)) echo 'successfully updated';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment