summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/database/query_builder/escape_test.php
diff options
context:
space:
mode:
authorTaufan Aditya <toopay@taufanaditya.com>2012-05-25 02:00:41 +0200
committerTaufan Aditya <toopay@taufanaditya.com>2012-05-25 02:00:41 +0200
commit502942bd94fef292970df331b15652ef6e1385e7 (patch)
tree8d773811a9f4bf3354d076855961f64ea78bc2d3 /tests/codeigniter/database/query_builder/escape_test.php
parent98dcac7ea5f82cc1d5cecedd030c5f242f1dc652 (diff)
Explicitely testing escape_like_str API
Diffstat (limited to 'tests/codeigniter/database/query_builder/escape_test.php')
-rw-r--r--tests/codeigniter/database/query_builder/escape_test.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/codeigniter/database/query_builder/escape_test.php b/tests/codeigniter/database/query_builder/escape_test.php
index 5dd2da058..ac1c8f659 100644
--- a/tests/codeigniter/database/query_builder/escape_test.php
+++ b/tests/codeigniter/database/query_builder/escape_test.php
@@ -13,6 +13,9 @@ 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) ? '!' : '';
}
// ------------------------------------------------------------------------
@@ -23,8 +26,8 @@ class Escape_test extends CI_TestCase {
public function test_escape_like_percent_sign()
{
$string = $this->db->escape_like_str('\%foo');
- $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%'";
- $sql .= (strpos(DB_DRIVER, 'mysql') !== FALSE) ? ";" : "ESCAPE '!';";
+
+ $sql = "SELECT {$this->pre}value{$this->pre} FROM {$this->pre}misc{$this->pre} WHERE {$this->pre}key{$this->pre} LIKE '$string%' ESCAPE '$this->esc';";
$res = $this->db->query($sql)->result_array();
@@ -40,8 +43,9 @@ class Escape_test extends CI_TestCase {
public function test_escape_like_backslash_sign()
{
$string = $this->db->escape_like_str('\\');
- $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%'";
- $sql .= (strpos(DB_DRIVER, 'mysql') !== FALSE) ? ";" : "ESCAPE '!';";
+
+ $sql = "SELECT {$this->pre}value{$this->pre} FROM {$this->pre}misc{$this->pre} WHERE {$this->pre}key{$this->pre} LIKE '$string%' ESCAPE '$this->esc';";
+
$res = $this->db->query($sql)->result_array();
// Check the result