|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-02-28 00:51 UTC] ethan dot nelson at ltd dot org
Description:
------------
I'm using PDO and the ODBC extension. Also I've installed the latest version of the SQL 2005 client tools so that I could create a System DSN using the SQLNative driver.
That in place, I've run into trouble when selecting data out of nvarchar(max) fields. nvarchar works fine, nvarchar(max) fails.
Additionally, it appears that I can insert data into these columns without issue.
Try something simple...
Reproduce code:
---------------
$pdo = new PDO("odbc:systemdsn");
$query = "SELECT CAST('asdfasdfasdf' AS nvarchar) AS good, CAST('asdfasdfasdf' AS nvarchar(max)) AS garbled";
$poo = $pdo->prepare($query);
$poo->execute();
$row = $poo->fetch(PDO::FETCH_ASSOC);
print_r($row);
Expected result:
----------------
Array ( [good] => asdfasdfasdf [garbled] => asdfasdfasdf )
Actual result:
--------------
Array ( [good] => asdfasdfasdf [garbled] => ��L �L��� )
Patchesvarcharmax-fix-v2.diff (last revision 2017-11-18 11:30 UTC by chris at ocproducts dot com)varcharmax-fix.diff (last revision 2017-11-17 03:35 UTC by chris at ocproducts dot com) Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 23:00:01 2025 UTC |
<?php ini_set("display_errors","yes"); $poo = new PDO("odbc:DEVELOPMENT"); $query = "SELECT CAST('asdfasdfasdf' AS nvarchar) AS good, CAST('asdfasdfasdf' AS nvarchar(max)) AS garbled"; $stm = $poo->prepare($query); echo $query."<br>\n"; $id = 1; $stm->bindParam(':id',$id,PDO::PARAM_INT); $id2 = 1; $stm->bindParam(':id2',$id2,PDO::PARAM_INT); echo "<pre>\n"; if ($stm->execute()) print_r($stm->fetchAll(PDO::FETCH_ASSOC)); else print_r( $stm->errorInfo()); echo "</pre>\n"; phpinfo(); ?> -----------Results in: SELECT CAST('asdfasdfasdf' AS nvarchar) AS good, CAST('asdfasdfasdf' AS nvarchar(max)) AS garbled Array ( [0] => Array ( [good] => asdfasdfasdf [garbled] => ? ? ) ) PHP Version 5.2.7RC2-devNo difference in behavior from what I can see. Can you reproduce the bug on your end? My screen reports the following using my reproduce code (with a few lines from the phpinfo command()): SELECT CAST('asdfasdfasdf' AS nvarchar) AS good, CAST('asdfasdfasdf' AS nvarchar(max)) AS garbled Array ( [0] => Array ( [good] => asdfasdfasdf [garbled] => �?[(?[��� ) ) PHP Logo PHP Version 5.2.10-dev System Windows NT LTD-PWWW2 5.2 build 3790 Build Date May 19 2009 11:39:28 Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--with-snapshot-template=d:\php-sdk\bin\\..\snap_5_2\vc6\x86\template" "--with-php-build=d:\php-sdk\bin\\..\snap_5_2\vc6\x86\php_build" "--with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared" Server API ISAPI