• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[2.1.1] Active Record quotes marks issues

I tried a lot of ways and I couldn't find a way to make my 'WHERE' clauses work properly.

My testing code:
         ->where("table1.t1_id = table2.t1_id")
         ->where("table1.t1_id", "table2.t1_id")
         ->where("table1.t1_id !=", "table2.t1_id")
         ->where("table1.t1_id", "table2.t1_id", FALSE);
$query = $this->db->get("table1, table2");
echo $this->db->last_query();

SELECT "table1".*
FROM "table1", "table2"
WHERE "table1"."t1_id" "= table2"."t1_id"
AND "table1"."t1_id" =  'table2.t1_id'
AND "table1"."t1_id" "!=" 'table2.t1_id'
AND table1.t1_id = table2.t1_id
As you can see, the 'equal' sign is receiving quotes marks

in 2.1.0 the result was
SELECT "table1".*
FROM "table1", "table2"
WHERE "table1"."t1_id" = table2.t1_id
AND "table1"."t1_id" =  'table2.t1_id'
AND "table1"."t1_id" != 'table2.t1_id'
AND table1.t1_id = table2.t1_id

The first 'where' is the one which I've been using since I began to work with CI. I don't really want to set FALSE for escape parameter for EVERY single 'where' clause I have.

Am I doing something wrong? Tested only on Postgres.

It seems it's related to these bugs:


->where("table1.t1_id = table2.t1_id")
// should be
->where("table1.t1_id =", "table2.t1_id")

My 3th example of where clause is something like that and is not working also.

The only difference is in my example I'm using != and not =

[eluser]Costa Rica SEO[/eluser]
Same here:

$custom_where = "`menu_item` > 0 AND `subdomain` = '{$this->subdomain}' OR `menu_item` = 1 AND `subdomain` = ''";

$query = $this->db
  ->order_by('menu_item ASC, order ASC')

Results in:

SELECT `menu_name`, `url`, `security`, `menu_item`, `ssl_required`, `menu_class`, `title`
FROM (`CI_CORE_Pages`)
WHERE `menu_item` `> 0 AND `subdomain` = 'www' OR `menu_item` = 1 AND `subdomain` = ''`
ORDER BY `menu_item` `ASC`, `order` `ASC`

Notice that both the WHERE and ORDER BY are both broken.

I've posted a suggested fix: https://github.com/EllisLab/CodeIgniter/issues/1469 which has fixed this issue for Datamapper.

Basically all components of a query which contain 2 spaces (i.e. something more then "string string" or ""string AS string") are incorrectly quoted by the DB_driver.

Would like to chime in that I, too, have issue with this update in 2.1.1.

Edit: BTW, the "fix" for 2.1.1 basically causes the ar_no_escape argument to be worthless, as it escapes the stuff anyway.

Hard to believe something this big wasn't discovered during some sort of testing.

Maybe there will be a quick v2.1.2

[eluser]Corey Wynsma[/eluser]
Same here... even something simple like
$this->db->where('field <', 25);
is getting strange escape results... and the no_escape arg doesn't seem to be working. Initially saw this on a custom where using BETWEEN.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.