Commit d61612df authored by rongzhj's avatar rongzhj

re-formatted code

parent 75030a1e
......@@ -821,20 +821,20 @@ class MysqliDb
}
foreach ($this->_updateColumns as $column) {
$this->_query .= "`" . $column . "` = ";
// Simple value
if (!is_array ($tableData[$column])) {
$this->_bindParam($tableData[$column]);
$this->_query .= '?, ';
continue;
}
// Function value
$arr = $tableData[$column];
$key = key($arr);
$val = $arr[$key];
switch ($key) {
$this->_query .= "`" . $column . "` = ";
// Simple value
if (!is_array ($tableData[$column])) {
$this->_bindParam($tableData[$column]);
$this->_query .= '?, ';
continue;
}
// Function value
$arr = $tableData[$column];
$key = key($arr);
$val = $arr[$key];
switch ($key) {
case '[I]':
$this->_query .= $column . $val . ", ";
break;
......@@ -851,7 +851,7 @@ class MysqliDb
break;
default:
die ("Wrong operation");
}
}
}
$this->_query = rtrim($this->_query, ', ');
}
......
......@@ -32,7 +32,7 @@ $tables = Array (
'updatedAt' => 'datetime',
'expires' => 'datetime',
'loginCount' => 'int(10) default 0',
'unique key' => 'login (login)'
'unique key' => 'login (login)'
),
'products' => Array (
'customerId' => 'int(10) not null',
......@@ -178,16 +178,16 @@ if ($db->count != 3) {
// insert with on duplicate key update
$user = Array ('login' => 'user3',
'active' => true,
'customerId' => 11,
'firstName' => 'Pete',
'lastName' => 'D',
'password' => $db->func('SHA1(?)',Array ("secretpassword2+salt")),
'createdAt' => $db->now(),
'updatedAt' => $db->now(),
'expires' => $db->now('+1Y'),
'loginCount' => $db->inc(3)
);
'active' => true,
'customerId' => 11,
'firstName' => 'Pete',
'lastName' => 'D',
'password' => $db->func('SHA1(?)',Array ("secretpassword2+salt")),
'createdAt' => $db->now(),
'updatedAt' => $db->now(),
'expires' => $db->now('+1Y'),
'loginCount' => $db->inc(3)
);
$updateColumns = Array ("updatedAt");
$insertLastId = "id";
$db->onDuplicate($updateColumns, "id");
......
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