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: db query '?' bind is not working when use sql with ':=' operator. #2762

Closed
fz19 opened this issue Mar 27, 2020 · 1 comment · Fixed by #2773
Closed

Bug: db query '?' bind is not working when use sql with ':=' operator. #2762

fz19 opened this issue Mar 27, 2020 · 1 comment · Fixed by #2773
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@fz19
Copy link

fz19 commented Mar 27, 2020

Describe the bug
Database Query '?' Bind is not working when use sql with ':=' operator.

CodeIgniter 4 version
v4.0.2

Affected module(s)
CodeIgniter\Database\Query (system/Database/Query.php)

Expected behavior, and steps to reproduce if appropriate

i use MySQL 5.7.28 and MySQLi driver.

$db = db_connect();
$sql = 'SELECT @factora := ?, @factorB := ?';
$params = [1,2];
$db->query($sql, $params);

i expected run query.
SELECT @factorA := 1, @factorB := 2.

but it was run query actually
SELECT @factorA := ?, @factorB := ?
and occured SQL syntax error.

it seem to understand NamedBind because the sql has ':=' operator.
so i fix ci4 code temporarily.

system/Database/Query.php :: compileBinds() line 371

$hasNamedBinds = strpos($sql, ':=') === false && strpos($sql, ':') !== false;

i hope solve this problem.
thanks.

Context

  • OS: CentOS Linux release 8.1.1911
  • Web server: nginx/1.17.6
  • PHP version: 7.4.3 (php-fpm)
@fz19 fz19 added the bug Verified issues on the current code behavior or pull requests that will fix them label Mar 27, 2020
@musmanikram
Copy link
Contributor

musmanikram commented Mar 29, 2020

Let me have a look

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.

2 participants