ID: 44278 User updated by: ethan dot nelson at ltd dot org Reported By: ethan dot nelson at ltd dot org -Status: Feedback +Status: Open Bug Type: PDO related Operating System: win2k3 PHP Version: 5.2.5 New Comment:
<?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-dev Previous Comments: ------------------------------------------------------------------------ [2008-10-21 11:32:36] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows: http://windows.php.net/snapshots/ ------------------------------------------------------------------------ [2008-02-28 00:51:28] 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��� ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44278&edit=1