I wanted $this->db->select() to support the dbprefix. The standard CI base does not support this. I made the following modification to enable it.
function select($select = '*')
{
if (is_string($select))
{
$select = explode(',', $select);
}
foreach ($select as $val)
{
$val = trim($val);
if ($val != '')
{
/* Begin RGT 25 Apr 2007 */
// Replace any word.word with PREFIXword.word
if ($this->dbprefix)
{
$val = preg_replace('|([\w\.]+\.[\w\.]+)|', $this->dbprefix . "$1", $val);
}
/* End RGT 25 Apr 2007 */
$this->ar_select[] = $val;
}
}
return $this;
}
With this I can now write the following:
Assuming that dbprefix = ‘a_’ in config/database.php…
$this->db->select('cust.cust_id, cust.cust_name');
produces the following SQL:
SELECT a_cust.cust_id, a_cust.cust_name .....
