Commit 16d88ae2 authored by Alexander Butenko's avatar Alexander Butenko

Merge pull request #284 from avbdr/master

fixes
parents 20db85d5 bd30f30d
This diff is collapsed.
...@@ -11,7 +11,7 @@ $db = new Mysqlidb($mysqli); ...@@ -11,7 +11,7 @@ $db = new Mysqlidb($mysqli);
$db = new Mysqlidb(Array ( $db = new Mysqlidb(Array (
'host' => 'localhost', 'host' => 'localhost',
'username' => 'root', 'username' => 'root',
'password' => '', 'password' => '',
'db' => 'testdb', 'db' => 'testdb',
'prefix' => $prefix, 'prefix' => $prefix,
...@@ -102,6 +102,7 @@ $data = Array ( ...@@ -102,6 +102,7 @@ $data = Array (
function createTable ($name, $data) { function createTable ($name, $data) {
global $db; global $db;
//$q = "CREATE TABLE $name (id INT(9) UNSIGNED PRIMARY KEY NOT NULL"; //$q = "CREATE TABLE $name (id INT(9) UNSIGNED PRIMARY KEY NOT NULL";
$db->rawQuery("DROP TABLE IF EXISTS $name");
$q = "CREATE TABLE $name (id INT(9) UNSIGNED PRIMARY KEY AUTO_INCREMENT"; $q = "CREATE TABLE $name (id INT(9) UNSIGNED PRIMARY KEY AUTO_INCREMENT";
foreach ($data as $k => $v) { foreach ($data as $k => $v) {
$q .= ", $k $v"; $q .= ", $k $v";
...@@ -192,6 +193,15 @@ $updateColumns = Array ("updatedAt"); ...@@ -192,6 +193,15 @@ $updateColumns = Array ("updatedAt");
$insertLastId = "id"; $insertLastId = "id";
$db->onDuplicate($updateColumns, "id"); $db->onDuplicate($updateColumns, "id");
$db->insert("users", $user); $db->insert("users", $user);
$nUser = $db->where('login','user3')->get('users');
if ($db->count != 1) {
echo "onDuplicate update failed. ";
exit;
}
if ($nUser[0]['createdAt'] == $nUser[0]['updatedAt']) {
echo "onDuplicate2 update failed. ";
exit;
}
// order by field // order by field
$db->orderBy("login","asc", Array ("user3","user2","user1")); $db->orderBy("login","asc", Array ("user3","user2","user1"));
...@@ -380,7 +390,7 @@ if ($db->totalCount != 3) { ...@@ -380,7 +390,7 @@ if ($db->totalCount != 3) {
$db->delete("users"); $db->delete("users");
$db->get("users"); $db->get("users");
if ($db->count != 0) { if ($db->count != 0) {
echo "Invalid users count after delete"; echo "Invalid users count after delete";
exit; exit;
} }
$db->delete("products"); $db->delete("products");
......
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