CodeIgniter Forums
4.1.3 => 4.1.5 DB Builder adding db prefix to table alias - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: 4.1.3 => 4.1.5 DB Builder adding db prefix to table alias (/showthread.php?tid=80559)



4.1.3 => 4.1.5 DB Builder adding db prefix to table alias - JoelC - 11-16-2021

After updating form CI 4.1.3 to 4.1.5 the query builder is adding the database prefix ( 'tbl' ) to an aliased table ( 'Profiles p' ) in the where statement of this query.
The previous version of CI did not add the database prefix in the orLike method.

Example:

PHP Code:
$searchString 'test'

$builder $this->db->table('Profiles p')
        ->select('p.ProfileID, p.FName, p.LName, p.EMail, p.SecondaryEMail')
        ->groupStart()
            ->orLike('p.FName'$searchString)
            ->orLike('p.LName'$searchString)
            ->orLike('p.Email'$searchString)
            ->orLike('p.SecondaryEMail'$searchString)
        ->groupEnd()
        ->limit(10); 
This produces the SQL string of:
Code:
SELECT `p`.`ProfileID`, `p`.`FName`, `p`.`LName`, `p`.`EMail`, `p`.`SecondaryEMail`
FROM `tblProfiles` `p`
WHERE  (`tbl``p`.`FName` LIKE '%test%' ESCAPE '!'OR  `tbl``p`.`LName` LIKE '%test%' ESCAPE '!'OR  `tbl``p`.`Email` LIKE '%test%' ESCAPE '!'OR  `tbl``p`.`SecondaryEMail` LIKE '%test%' ESCAPE '!' )
LIMIT 10



RE: 4.1.3 => 4.1.5 DB Builder adding db prefix to table alias - kenjis - 11-19-2021

Thank you for reporting.
I created an issue:
https://github.com/codeigniter4/CodeIgniter4/issues/5360


RE: 4.1.3 => 4.1.5 DB Builder adding db prefix to table alias - seunex - 11-19-2021

I think am the only one having this issue. My app is broken immediately I upgraded.

Also in the WHERE CLAUSE


RE: 4.1.3 => 4.1.5 DB Builder adding db prefix to table alias - kenjis - 11-19-2021

I sentt a PR: https://github.com/codeigniter4/CodeIgniter4/pull/5361


RE: 4.1.3 => 4.1.5 DB Builder adding db prefix to table alias - seunex - 11-20-2021

(11-19-2021, 11:30 PM)kenjis Wrote: I sentt a PR: https://github.com/codeigniter4/CodeIgniter4/pull/5361

Hello bro any temporary fix because i have been force to remove prefix from my db before my app started working again.


RE: 4.1.3 => 4.1.5 DB Builder adding db prefix to table alias - kenjis - 11-20-2021

Please fix system/Database/BaseConnection.php
https://github.com/codeigniter4/CodeIgniter4/pull/5361/files#diff-a0dd1b2b2b4cedd9717224db1b29e49a84991d770ef1b4a70c97721b1293e9a5L1015-R1016