Skip to content

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

Description

@fz19

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions