ID:               42768
 Updated by:       [email protected]
 Reported By:      sms at inbox dot ru
-Status:           Open
+Status:           Feedback
 Bug Type:         PDO related
 Operating System: Windows 2000 SP4
-PHP Version:      5.2.4
+PHP Version:      5.2.6
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/




Previous Comments:
------------------------------------------------------------------------

[2008-06-15 21:01:18] php080615 at prodpartners dot com

I have the same problem with PDO lobs returning hex coded strings under
Windows 2003 Server however my same code works under linux/freetds. 
Problem has persisted for over six months with various minor versions of
PHP 5.2.  Currently using 5.2.6 with Windows 2003 Server

------------------------------------------------------------------------

[2007-09-26 13:40:03] sms at inbox dot ru

Description:
------------
I try to get a long binary field from Microsoft SQL Server. This simple
thing is quite problematic with PDO ODBC. I already reported bug #42765.
Now I found a way to bypass it and faced another big problem.

PDO returns long binary fields always as HEX string which is also
corrupted. LOBs doesn't work at all... So there's simply no way to get
correct binary data with PDO.

So I'm forced to use ODBC unified extension.

Reproduce code:
---------------
<plaintext>
<?php
$dbh=new PDO('odbc:Driver={SQL
Server};Server=localhost;Database=test','user','pass');

$s=$dbh->prepare("set textsize 10485760; select [nbin] from [atts]
where [id]=1");
$s->bindColumn('nbin',$bin,PDO::PARAM_LOB);
$s->execute();
$s->fetch(PDO::FETCH_BOUND);
var_dump($bin);
?>

Note: "set textsize" to bypass bug #42765

Expected result:
----------------
$bin should be a stream object


Actual result:
--------------
$bin is a string instead:
string(385)
"24733D246462682D3E707265706172652822736574205445585453495A452031303438353736303B2073656C656374206E62696E2066726F6D2074626C417474732077686572652069644174743D363222293B0D0A24732D3E62696E64436F6C756D6E28276E62696E272C2462696E2C50444F3A3A504152414D5F4C4F4229&#65533;3B0D0A24732D3E6578656375746528293B0D0A24732D3E66657463682850444F3A3A46455443485F424F554E44293B0D0A7661725F64756D70282462696E29&#65533;&#65533;3B"

Why is it HEX-coded anyway?..

pack("H*",$bin) gives warning "illegal hex digit" and the result
differs from actual field value.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=42768&edit=1

Reply via email to