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

 ID:                 42768
 Comment by:         xilentd at gmail dot com
 Reported by:        sms at inbox dot ru
 Summary:            PDO ODBC: Lob doesn't work
 Status:             No Feedback
 Type:               Bug
 Package:            PDO related
 Operating System:   Windows 2000 SP4
 PHP Version:        5.2.6
 Block user comment: N
 Private report:     N

 New Comment:

There is a null-byte after every 254 symbols of blob, pack('H*', 
str_replace("\0", '', $blob)) works for me on Windows with Native Client.


Previous Comments:
------------------------------------------------------------------------
[2009-05-03 01:00:04] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

------------------------------------------------------------------------
[2009-04-25 14:50:55] j...@php.net

Please try using this CVS snapshot:

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

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



------------------------------------------------------------------------
[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 https://bugs.php.net/bug.php?id=42768&edit=1

Reply via email to