• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
$this->db->where bug?

[eluser]Darkroom Dave[/eluser]
I just upgraded from 1.7.0 to 1.7.1 and a few of my queries no longer work.


but will work if I change it to

$this->db->where("highlight = 1");

What error do you get with the no space version?
Does it fail to create the query, or just not return the expected results?

If you turn on the profiler, what is the generarated query for both cases? (there is also a function to return the SQL query, but can't remember its name, as I've never needed it)

Or just pass in 2 params


This way it should never break regardless of CI version

[quote author="warrennz" date="1240631645"]Or just pass in 2 params


This way it should never break regardless of CI version[/quote]

Yeah, thats a good way to do, as it future proofs you, but doesn't explain why his/her code has broken

[quote author="Dam1an" date="1240668453"]... but doesn't explain why his/her code has broken[/quote]

CI active record adds backticks to the entire string causing the error, the spaces allow it to add backticks correctly.

I ran the profiler on it to see what it was doing

SELECT * FROM (`categories`) WHERE `highlight=1` ORDER BY `orderid`

So it does break my existing code. Maybe it shouldn't back tick if there is a operator like = in there?

Obliviously it didn't before 1.7.1

I do usually use the array method but the same problem also broke this

$this->db->where(sprintf("parent_id=%s OR highlight=1", $id));

And yes I could of used or_where but I didn't

[quote author="darkroomdave" date="1240956248"]
$this->db->where(sprintf("parent_id=%s OR highlight=1", $id));[/quote]
I think its because you have nested logic, try setting the second parameter to false

To be clear. I am not trying to fixed this. Already fix days ago.

I am pointing out there was a change some place before 1.7.1 that breaks existing code.

Just trying to be helpful to others...

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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