Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: table has double prefix when LIKE clause #5775

Closed
iRedds opened this issue Mar 4, 2022 · 2 comments · Fixed by #5778
Closed

Bug: table has double prefix when LIKE clause #5775

iRedds opened this issue Mar 4, 2022 · 2 comments · Fixed by #5778
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@iRedds
Copy link
Collaborator

iRedds commented Mar 4, 2022

PHP Version

7.3

CodeIgniter4 Version

4.1.9 + dev

CodeIgniter4 Installation Method

Git

Which operating systems have you tested for this bug?

Windows

Which server did you use?

cli

Database

No response

What happened?

see https://forum.codeigniter.com/thread-81454.html

Steps to Reproduce

// database.default.DBPrefix = db_

db_connect()->table('test')->like('test.field', 'string')->getCompiledSelect();

// SELECT * FROM `db_test` WHERE `db_``db_test`.`field` LIKE '%string%' ESCAPE '!' 

Expected Output

SELECT * FROM `db_test` WHERE `db_test`.`field` LIKE '%string%' ESCAPE '!' 

Anything else?

No response

@iRedds iRedds added the bug Verified issues on the current code behavior or pull requests that will fix them label Mar 4, 2022
@joaisbn
Copy link

joaisbn commented Mar 30, 2022

I had the same error, using CI 4.1.9.

I think it can be solved replacing the operator !== ( not identical ) to != ( not equal ) in the BaseConnection.php on line 1061.

elseif (strpos($parts[$i], $this->DBPrefix) !== 0) {
to
elseif (strpos($parts[$i], $this->DBPrefix) != 0) {

@kenjis
Copy link
Member

kenjis commented Mar 30, 2022

@joaisbn This was fixed by #5778
Try the latest develop branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants