From 9930fc073aa39e257af7e875e55fffcf11c38cd5 Mon Sep 17 00:00:00 2001 From: Sergey Tsalkov Date: Fri, 3 Feb 2012 17:19:54 -0800 Subject: [PATCH] restore %lb parameter to working, add unit test so it doesn't break again --- db.class.php | 2 +- simpletest/BasicTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/db.class.php b/db.class.php index 89f6793..60aa8b2 100644 --- a/db.class.php +++ b/db.class.php @@ -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"); diff --git a/simpletest/BasicTest.php b/simpletest/BasicTest.php index 32f9fcd..2c34e82 100644 --- a/simpletest/BasicTest.php +++ b/simpletest/BasicTest.php @@ -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'); + } }