Skip to content

Commit

Permalink
Support dbprefix tablename setting
Browse files Browse the repository at this point in the history
  • Loading branch information
yidas committed Aug 29, 2023
1 parent abda725 commit 67f81e6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Base Model
*
* @author Nick Tsai <[email protected]>
* @version 2.19.2
* @version 2.19.3
* @see https://github.com/yidas/codeigniter-model
*/
class Model extends \CI_Model implements \ArrayAccess
Expand Down Expand Up @@ -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}`";
}

/**
Expand Down

0 comments on commit 67f81e6

Please sign in to comment.