CodeIgniter Forums
value quote bug in AR having() 1.6.1 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: value quote bug in AR having() 1.6.1 (/showthread.php?tid=7627)



value quote bug in AR having() 1.6.1 - El Forum - 04-16-2008

[eluser]BlueCamel[/eluser]
In CI 1.6.1 I ran into having() not quoting properly. I looked at the function _having() and noticed it was using escape_str() instead of escape() like function _where(). Chaning this solved my situation.

Simple test case:

$this->db->having('field', 'show stats -c')

Code:
--- DB_active_rec.php.orig      2008-04-16 21:59:16.000000000 -0400
+++ DB_active_rec.php   2008-04-16 21:59:24.000000000 -0400
@@ -824,7 +824,7 @@

                        if ($v != '')
                        {
-                               $v = ' '.$this->escape_str($v);
+                               $v = ' '.$this->escape($v);
                        }

                        $this->ar_having[] = $prefix.$k.$v;



value quote bug in AR having() 1.6.1 - El Forum - 04-17-2008

[eluser]Seppo[/eluser]
Well... it looks like a bug, certainly... Also I don't see an equal sign between the key and the value


value quote bug in AR having() 1.6.1 - El Forum - 04-17-2008

[eluser]BlueCamel[/eluser]
I don't think my patch fixes it either. Note that the docks give examples where having() and orhaving() are specified with = in both cases, unlike where() and orwhere().

In general, having() should be more like where() IMHO.