Skip to content

CI 3.1.13 and PHP 8.1: query builder with sqlsrv driver is trying to use backticks as the escape character #6320

@ssmutz

Description

@ssmutz

I recently upgraded my development server to PHP 8.1 due to Microsoft removing support for 8.0 from its pecl packages for sqlsrv. However I'm running in to this issue with queries created by query builder.

The queries being created are using backticks instead of double quotes or square brackets as the escape character.

When running most queries, I get errors like this

Error Number: 42000/102

[Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Incorrect syntax near '`'.

SELECT `RecordId`, `EmployeeId`, `TimeIn`, `TimeOut` FROM `EmployeeHours` WHERE `EmployeeId` = 1 ORDER BY `TimeIn` DESC OFFSET 0 ROWS FETCH NEXT 25 ROWS ONLY

Filename: models/Timeclock_model.php

Line Number: 111

Where as on my 8.0 production server, the same query is generated like this

SELECT "RecordId", "EmployeeId", "TimeIn", "TimeOut"
FROM "EmployeeHours"
WHERE "EmployeeId" = '1'
ORDER BY "TimeIn" DESC
OFFSET 0 ROWS FETCH NEXT 25 ROWS ONLY  

Writing out the full query string myself works, but is not ideal. I'd rather be able to continue to use the query builder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions