php - pdo-odbc doesn't work whit bind values, nvarchar and text are incompatible in the equal to operator -
there column url(nvarchar(200), not null)
<?php // $pdo = new pdo('odbc:mssql', 'xxx', 'yyy'); $pdo->setattribute(pdo::attr_persistent, false); $pdo->setattribute(pdo::attr_errmode, pdo::errmode_warning); // plain sql query: works fine! $sth = $pdo->prepare("select count(*) pagina url = '/webito'"); $sth->execute(); // using bindvalue: error! $sth = $pdo->prepare("select count(*) pagina url = :unique_value"); $sth->execute(array('unique_value' => '/webito'));
returning error:
warning: pdostatement::execute(): sqlstate[42000]: syntax error or access violation: 402 [freetds][sql server]the data types nvarchar , text incompatible in equal operator. (sqlexecute[402] @ /builddir/build/build/php-5.4.15/ext/pdo_odbc/odbc_stmt.c:254) in /root/php/test.php on line 13
is bug?
using: php 5.4.15, unixodbc 2.2.14, freetds 0.91, sql-server-2012, centos-x64 6.4
update:
seems bug. found patch, works odbc driver 11 sql server (i tried freetds, no luck). managed install php source patch applied , changed freetds odbc driver 11 sql server; working.
- php 5.4.15
- unixodbc 2.3.0
- odbc driver 11 sql server
- sql-server-2012
- centos-x64 6.4
having done fair bit of research seems pdo_odbc buggy on 64-bit architectures: it's built 32-bit sqllen , sqlulen sizes. microsoft's driver used built way, why php followed suit. ms have since started follow odbc spec properly, apparently php hasn't.
the patch referenced in question fixes 1 such problem in php source, seemingly not such problems. using ms driver , patched php still unable run prepared statements.
i found same problem when using easysoft's driver, , talking through issues them discovered pdo_odbc culprit. able provide me 64-bit driver built using 32-bit sizes, , works fine.
until 64-bit php patched use 64-bit sqllen , sqlulen sizes looks best free solution use 32-bit php , odbc drivers.
Comments
Post a Comment