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

#1
[eluser]Nom4d3[/eluser]
I tried a lot of ways and I couldn't find a way to make my 'WHERE' clauses work properly.

My testing code:
Code:
$this->db->select("table1.*")
         ->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();

Result:
Code:
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
Code:
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.

#2
[eluser]Nom4d3[/eluser]
It seems it's related to these bugs:

https://github.com/EllisLab/CodeIgniter/issues/1469
https://github.com/EllisLab/CodeIgniter/issues/1471

#3
[eluser]InsiteFX[/eluser]
Code:
->where("table1.t1_id = table2.t1_id")
// should be
->where("table1.t1_id =", "table2.t1_id")

#4
[eluser]Nom4d3[/eluser]
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 =


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

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

$query = $this->db
  ->select('menu_name,url,security,menu_item,ssl_required,menu_class,title')
  ->from('CORE_Pages')
  ->where($custom_where)
  ->order_by('menu_item ASC, order ASC')
  ->get();

Results in:

Code:
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.

#6
[eluser]WanWizard[/eluser]
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.

#7
[eluser]bcorcoran[/eluser]
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.

#8
[eluser]CroNiX[/eluser]
Hard to believe something this big wasn't discovered during some sort of testing.

#9
[eluser]skunkbad[/eluser]
Maybe there will be a quick v2.1.2

#10
[eluser]Corey Wynsma[/eluser]
Same here... even something simple like
Code:
$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.