|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-09-26 13:40 UTC] 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�3B0D0A24732D3E6578656375746528293B0D0A24732D3E66657463682850444F3A3A46455443485F424F554E44293B0D0A7661725F64756D70282462696E29��3B" Why is it HEX-coded anyway?.. pack("H*",$bin) gives warning "illegal hex digit" and the result differs from actual field value. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 05:00:01 2025 UTC |
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.