restore %lb parameter to working, add unit test so it doesn't break again

This commit is contained in:
Sergey Tsalkov
2012-02-03 17:19:54 -08:00
parent 788c506f16
commit 9930fc073a
2 changed files with 13 additions and 1 deletions

View File

@@ -463,7 +463,7 @@ class MeekroDB {
if ($type == 'ls') $result = $this->wrapStr($arg, "'", true);
else if ($type == 'li') $result = array_map('intval', $arg);
else if ($type == 'ld') $result = array_map('floatval', $arg);
else if ($type == 'lb') $result = array_map('$this->formatTableName', $arg);
else if ($type == 'lb') $result = array_map(array($this, 'formatTableName'), $arg);
else if ($type == 'll') $result = $arg;
else if (! $result) $this->nonSQLError("Badly formatted SQL query: $sql");

View File

@@ -304,6 +304,18 @@ class BasicTest extends SimpleTest {
DB::query("UPDATE accounts SET age=15, username='Bart' WHERE age=%i", 74);
$this->assert(DB::affectedRows() === 1);
}
function test_8_lb() {
$data = array(
'username' => 'vookoo',
'password' => 'dookoo',
);
DB::query("INSERT into accounts %lb VALUES %ls", array_keys($data), array_values($data));
$result = DB::query("SELECT * FROM accounts WHERE username=%s", 'vookoo');
$this->assert(count($result) === 1);
$this->assert($result[0]['password'] === 'dookoo');
}
}