Welcome Guest, Not a member yet? Register   Sign In
4.1.3 => 4.1.5 DB Builder adding db prefix to table alias
#1

(This post was last modified: 11-16-2021, 12:30 PM by JoelC.)

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
Reply
#2

Thank you for reporting.
I created an issue:
https://github.com/codeigniter4/CodeIgni...ssues/5360
Reply
#3

(This post was last modified: 11-19-2021, 10:44 PM by seunex.)

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

Also in the WHERE CLAUSE
Reply
#4

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

(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.
Reply
#6

Please fix system/Database/BaseConnection.php
https://github.com/codeigniter4/CodeIgni...1015-R1016
Reply




Theme © iAndrew 2016 - Forum software by © MyBB