Welcome Guest, Not a member yet? Register   Sign In
Problems with sqlsrv DB driver and CI 3
#1

(This post was last modified: 05-28-2015, 05:38 AM by dimas.)

Hi,

I'm migrating my web app from CI 2.x to CI 3.0. My app uses the 'sqlsrv' driver.

When I try to open my web app I get database errors, for example:

Code:
Error Number: 42000/102

[Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax near ')'.

SELECT "Data" "Data" FROM (SELECT cf.idCalendari idCalendari, "f"."Data"" FROM GT_CalendarisFestius cf LEFT JOIN GT_Festius f ON cf"."idCalendari = f"."idCalendari)" "festius" WHERE "festius"."idCalendari" IN(5, 6)

I don't know why CI 3 are putting doble quotes inside the SQL, and are doing it badly (as you can see the SQL is bad constructed).

The model is this:


Code:
$this->db->select('Data Data');
$this->db->from('(SELECT cf.idCalendari idCalendari, f."Data" FROM GT_CalendarisFestius cf LEFT JOIN GT_Festius f ON cf.idCalendari = f.idCalendari) festius');
$this->db->where_in('festius.idCalendari', array(5,6));

The same happens with a SELECT like this:

Code:
$this->db->select("CONVERT(VARCHAR(10),a.Dia,105) as Day")

It get transformed to this:

Code:
SELECT CONVERT(VARCHAR(10), "a"."Dia", "105 )" as "Day"

How can I solve it? Is it possible to disable this double quote annoying bug?

Thx
Reply


Messages In This Thread
Problems with sqlsrv DB driver and CI 3 - by dimas - 05-28-2015, 03:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB