sqlite insert test
This commit is contained in:
parent
15672b6928
commit
0022126b96
@ -424,10 +424,8 @@ class Query_Builder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use the keys of the array to make the insert/update string
|
// Use the keys of the array to make the insert/update string
|
||||||
$this->set_array_keys = array_keys($this->set_array);
|
|
||||||
|
|
||||||
// Escape the field names
|
// Escape the field names
|
||||||
$this->set_array_keys = array_map(array($this, 'quote_ident'), $this->set_array_keys);
|
$this->set_array_keys = array_map(array($this->db, 'quote_ident'), array_keys($this->set_array));
|
||||||
|
|
||||||
// Generate the "set" string
|
// Generate the "set" string
|
||||||
$this->set_string = implode('=?, ', $this->set_array_keys);
|
$this->set_string = implode('=?, ', $this->set_array_keys);
|
||||||
@ -587,10 +585,10 @@ class Query_Builder {
|
|||||||
|
|
||||||
case "insert":
|
case "insert":
|
||||||
$param_count = count($this->set_array);
|
$param_count = count($this->set_array);
|
||||||
$params = array_file(0, $param_count, '?');
|
$params = array_fill(0, $param_count, '?');
|
||||||
$sql = 'INSERT (' . implode(', ', $this->set_array_keys) .
|
$sql = 'INSERT INTO '. $this->db->quote_ident($table) .
|
||||||
') INTO '. $this->quote_ident($table) .
|
'(' . implode(', ', $this->set_array_keys) .
|
||||||
'VALUES ('.implode(', ', $params).')';
|
') VALUES ('.implode(', ', $params).')';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "delete":
|
case "delete":
|
||||||
@ -598,6 +596,8 @@ class Query_Builder {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo $sql.'<br />';
|
||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,4 +100,14 @@
|
|||||||
|
|
||||||
$this->assertIsA($query, 'PDOStatement');
|
$this->assertIsA($query, 'PDOStatement');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function TestInsert()
|
||||||
|
{
|
||||||
|
$query = $this->qb->set('id', 4)
|
||||||
|
->set('key', 4)
|
||||||
|
->set('val', 5)
|
||||||
|
->insert('create_test');
|
||||||
|
|
||||||
|
$this->assertIsA($query, 'PDOStatement');
|
||||||
|
}
|
||||||
}
|
}
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user