From bb433723c84e174ed87a1daf46017866c32c83c8 Mon Sep 17 00:00:00 2001 From: Rick Ellis Date: Mon, 5 Feb 2007 22:32:49 +0000 Subject: --- system/database/DB_active_rec.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 90f58ae0e..d27d3dc1e 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -134,7 +134,17 @@ class CI_DB_active_record extends CI_DB_driver { $type .= ' '; } } - + + // If a DB prefix is used we might need to add it to the column names + if ($this->dbprefix) + { + // First we remove any existing prefixes in the condition to avoid duplicates + $cond = preg_replace('|('.$this->dbprefix.')([\w\.]+)([\W\s]+)|', "$2$3", $cond); + + // Next we add the prefixes to the condition + $cond = preg_replace('|([\w\.]+)([\W\s]+)(.+)|', $this->dbprefix . "$1$2" . $this->dbprefix . "$3", $cond); + } + $this->ar_join[] = $type.'JOIN '.$this->dbprefix.$table.' ON '.$cond; return $this; } -- cgit v1.2.3-24-g4f1b