diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-12-17 21:05:47 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-12-17 21:05:47 -0800 |
commit | 2aba8c4bffed5fb38689d5ed998c486ab6bde902 (patch) | |
tree | ca015c9d81b6cd3bd6055d61c359063aa0350a09 /modules/gallery/libraries/MY_Database.php | |
parent | c99a75b5d150f14c96697833f08354afd456323a (diff) |
Simplify add_table_prefixes. In Kohana 2.4, it returns the bare table
name, not the prefixed one so this makes our logic easier.
Diffstat (limited to 'modules/gallery/libraries/MY_Database.php')
-rw-r--r-- | modules/gallery/libraries/MY_Database.php | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/modules/gallery/libraries/MY_Database.php b/modules/gallery/libraries/MY_Database.php index 52bc46d6..fd486039 100644 --- a/modules/gallery/libraries/MY_Database.php +++ b/modules/gallery/libraries/MY_Database.php @@ -25,7 +25,7 @@ abstract class Database extends Database_Core { * table prefix . $1 */ public function query($sql = '') { - if (!empty($sql)) { + if ($this->config["table_prefix"] && !empty($sql)) { $sql = $this->add_table_prefixes($sql); } return parent::query($sql); @@ -49,19 +49,12 @@ abstract class Database extends Database_Core { if (!isset($this->_table_names)) { // This should only run once on the first query - $this->_table_names =array(); - $len = strlen($prefix); + $this->_table_names = array(); foreach($this->list_tables() as $table_name) { - if ($len > 0) { - $naked_name = strpos($table_name, $prefix) !== 0 ? - $table_name : substr($table_name, $len); - } else { - $naked_name = $table_name; - } - $this->_table_names["{{$naked_name}}"] = $table_name; + $this->_table_names["{{$table_name}}"] = $prefix . $table_name; } } - return empty($this->_table_names) ? $sql : strtr($sql, $this->_table_names); + return strtr($sql, $this->_table_names); } }
\ No newline at end of file |