From 67f81e6efb5559abf5ecd351a46233424163e4d0 Mon Sep 17 00:00:00 2001 From: Nick Tsai Date: Tue, 29 Aug 2023 19:01:59 +0800 Subject: [PATCH] Support dbprefix tablename setting --- src/Model.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Model.php b/src/Model.php index 45719b0..1b5ff35 100644 --- a/src/Model.php +++ b/src/Model.php @@ -8,7 +8,7 @@ * Base Model * * @author Nick Tsai - * @version 2.19.2 + * @version 2.19.3 * @see https://github.com/yidas/codeigniter-model */ class Model extends \CI_Model implements \ArrayAccess @@ -1586,7 +1586,15 @@ protected function _addGlobalScopeCondition() */ protected function _field($columnName) { - return ($this->alias) ? "`{$this->alias}`.`{$columnName}`" : "`{$this->table}`.`{$columnName}`"; + if ($this->alias) { + return "`{$this->alias}`.`{$columnName}`"; + } + + if ($this->_db->dbprefix) { + return "{$this->table}.`{$columnName}`"; + } + + return "`{$this->table}`.`{$columnName}`"; } /**