summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Ellis <rick.ellis@ellislab.com>2007-02-05 23:32:49 +0100
committerRick Ellis <rick.ellis@ellislab.com>2007-02-05 23:32:49 +0100
commitbb433723c84e174ed87a1daf46017866c32c83c8 (patch)
tree969713a493401e70f6d79c40ec1f0990dfb6ca7d
parentc1ee65ba12164141b18aac49b0f210ed161f88b9 (diff)
-rw-r--r--system/database/DB_active_rec.php12
1 files changed, 11 insertions, 1 deletions
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;
}