summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTaufan Aditya <toopay@taufanaditya.com>2012-05-26 11:04:39 +0200
committerTaufan Aditya <toopay@taufanaditya.com>2012-05-26 11:04:39 +0200
commit1af5b47ad6f95f805d9f411ce020f2e2fa88b302 (patch)
treef4553ae815f16696fd1e36c03f8a2d247881ab4a /tests
parent3c5abf93d3031064c8181069cfee83ebfb54dcf0 (diff)
Remove ternary
Diffstat (limited to 'tests')
-rw-r--r--tests/codeigniter/database/query_builder/escape_test.php24
1 files changed, 18 insertions, 6 deletions
diff --git a/tests/codeigniter/database/query_builder/escape_test.php b/tests/codeigniter/database/query_builder/escape_test.php
index 5df812ca6..5d575a37b 100644
--- a/tests/codeigniter/database/query_builder/escape_test.php
+++ b/tests/codeigniter/database/query_builder/escape_test.php
@@ -13,9 +13,6 @@ class Escape_test extends CI_TestCase {
Mock_Database_Schema_Skeleton::create_tables();
Mock_Database_Schema_Skeleton::create_data();
-
- $this->pre = (strpos(DB_DRIVER, 'pgsql') === FALSE) ? '`' : '"';
- $this->esc = (strpos(DB_DRIVER, 'mysql') === FALSE) ? '!' : '';
}
// ------------------------------------------------------------------------
@@ -25,9 +22,17 @@ class Escape_test extends CI_TestCase {
*/
public function test_escape_like_percent_sign()
{
+ // Escape the like string
$string = $this->db->escape_like_str('\%foo');
- $sql = "SELECT {$this->pre}value{$this->pre} FROM {$this->pre}misc{$this->pre} WHERE {$this->pre}key{$this->pre} LIKE '$string%' ESCAPE '$this->esc';";
+ if (strpos(DB_DRIVER, 'mysql') !== FALSE)
+ {
+ $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%' ESCAPE '';";
+ }
+ else
+ {
+ $sql = 'SELECT "value" FROM "misc" WHERE "key" LIKE \''.$string.'%\' ESCAPE \'!\';';
+ }
$res = $this->db->query($sql)->result_array();
@@ -42,14 +47,21 @@ class Escape_test extends CI_TestCase {
*/
public function test_escape_like_backslash_sign()
{
+ // Escape the like string
$string = $this->db->escape_like_str('\\');
- $sql = "SELECT {$this->pre}value{$this->pre} FROM {$this->pre}misc{$this->pre} WHERE {$this->pre}key{$this->pre} LIKE '$string%' ESCAPE '$this->esc';";
+ if (strpos(DB_DRIVER, 'mysql') !== FALSE)
+ {
+ $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%' ESCAPE '';";
+ }
+ else
+ {
+ $sql = 'SELECT "value" FROM "misc" WHERE "key" LIKE \''.$string.'%\' ESCAPE \'!\';';
+ }
$res = $this->db->query($sql)->result_array();
// Check the result
$this->assertEquals(2, count($res));
}
-
} \ No newline at end of file