I use the SQL server 2008 native client 10.0 to connect (via odbc) my php program to a SQL Server 2008 express edititon. Everything works fine except for specifying bound parameters within subqueries, such as this one:$q = 'select f.id from (select id from foo where id = ?) as f';the error message I get is:SQLSTATE[22018]: Invalid character value for cast specification: 206 [Microsoft][SQL Native Client][SQL Server]Er is een conflict met het type operand ontstaan: text is incompatibel met int (SQLExecute[206] at ext\pdo_odbc\odbc_stmt.c:254)(in english this is: 'there is a conflict with the type operand: text is incompatible with int')If I use e.g. this query: $q = 'select f.id from foo f where id=?';or e.g. this one$q = 'select f.id from (select id from foo where id = 1) as f';everything works fine and I get id=1 as a result.Note, that if I use the same code but with another database like mysql (using the odbc mysql driver v3.51) this works fine, so it isn't the pdo_odbc code from php.The same error occurs when using the SQL server driver for PHP version 1.1. The same error occurs when using the 'SQL Server' driver in the dsn instead of SQL Server Native Client 10.0.I use this $dsn: "Driver={SQL Server Native Client 10.0};Server={localhost\SQLEXPRESS};Database={foo};Uid={[user]};Pwd={[password]};";There is a similar report about this problem filed in the bug list of php. But this is clearly no bug in PHP but in SQL Server driver. You can find the php bug report here: http://bugs.php.net/bug.php?id=36561. They found out that using a profiler the sql that SQL Server driver produces is N'@P1 text' where it should be N'@P1 int'.Apperantly this is a bug since beginning of 2006 and it was already in SQL Server 2005. So in SQL Server 2008 this is still not solved.The problem with this is that ORM's cannot work (via odbc) with SQL Server, since they work frequently with these kind of sql statements, like doctrine. This is a big problem for people who are forced to work with a SQL Server
Version
Category
Operating System
Platform