From 740ca7bc67d42dc15ed7b165ca9ff591679a29d9 Mon Sep 17 00:00:00 2001 From: Sergey Tsalkov Date: Fri, 21 Jun 2013 16:27:05 -0700 Subject: [PATCH] restore %ss to working, add unit test so it won't break again --- db.class.php | 2 +- simpletest/BasicTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db.class.php b/db.class.php index 4619d3a..a5961d6 100644 --- a/db.class.php +++ b/db.class.php @@ -539,7 +539,7 @@ class MeekroDB { else if ($type == 'd') $result = doubleval($arg); else if ($type == 'b') $result = $this->formatTableName($arg); else if ($type == 'l') $result = $arg; - else if ($type == 'ss') $result = "%" . $this->escape(str_replace(array('%', '_'), array('\%', '\_'), $arg)) . "%"; + else if ($type == 'ss') $result = $this->escape("%" . str_replace(array('%', '_'), array('\%', '\_'), $arg) . "%"); else if ($type == 't') $result = $this->escape($this->parseTS($arg)); else if ($type == 'ls') $result = array_map(array($this, 'escape'), $arg); diff --git a/simpletest/BasicTest.php b/simpletest/BasicTest.php index ad153c3..dbd7f3f 100644 --- a/simpletest/BasicTest.php +++ b/simpletest/BasicTest.php @@ -256,7 +256,7 @@ class BasicTest extends SimpleTest { $this->assert($rows[1]['password'] === 'somethingelse'); $this->assert($rows[1]['username'] === '2ofmany'); - $nullrow = DB::queryOneRow("SELECT * FROM accounts WHERE username=%s", '3ofmany'); + $nullrow = DB::queryOneRow("SELECT * FROM accounts WHERE username LIKE %ss", '3ofman'); $this->assert($nullrow['password'] === NULL); $this->assert($nullrow['age'] === '15'); }