Welcome Guest, Not a member yet? Register   Sign In
SQL functions in get_where.
#1

[eluser]Unknown[/eluser]
Is there a way to do this in CI?

$data['scInfo'] = $this->db->get_where(TBL_SUBCATEGORIES, array('SOUNDEX(name)=SOUNDEX(?)' => fromURL($this->uri->segment(3)), 'catId' => $data['cInfo']->id))->first_row();

-

The query that code generates is

SELECT `id`, `name`, `shortdesc` FROM (`subcategories`) WHERE SOUNDEX(name)=SOUNDEX(?) 'iPod Gaming and Phone Accessories' AND `catId` = '15' ORDER BY `name` desc

It should be

SELECT `id`, `name`, `shortdesc` FROM (`subcategories`) WHERE SOUNDEX(name)=SOUNDEX('iPod Gaming and Phone Accessories') AND `catId` = '15' ORDER BY `name` desc
#2

[eluser]Unknown[/eluser]
Doesn't seem to be an option.

Here's a patch (albeit a bit quick and hacky) that enables it.


Code:
--- system/database/DB_active_rec.php.org    2010-07-12 10:44:21.000000000 +1000
+++ system/database/DB_active_rec.php    2010-07-12 10:47:39.000000000 +1000
@@ -463,11 +463,11 @@
                 $k = $this->_protect_identifiers($k, FALSE, $escape);
             }

-            $this->ar_where[] = $prefix.$k.$v;
+            $this->ar_where[] = $prefix.(strpos($k, $this->bind_marker) === FALSE ? $k.$v : $this->compile_binds($k, array($v)));

             if ($this->ar_caching === TRUE)
             {
-                $this->ar_cache_where[] = $prefix.$k.$v;
+                $this->ar_cache_where[] = $prefix.(strpos($k, $this->bind_marker) === FALSE ? $k.$v : $this->compile_binds($k, array($v)));
                 $this->ar_cache_exists[] = 'where';
             }




Theme © iAndrew 2016 - Forum software by © MyBB