<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" > <channel><title>Comments on: Handling Binary Data with PDO</title> <atom:link href="http://jeremycook.ca/2010/02/21/handling-binary-data-with-pdo/feed/" rel="self" type="application/rss+xml" /><link>http://jeremycook.ca/2010/02/21/handling-binary-data-with-pdo/</link> <description>Random musings on web development and PHP</description> <lastBuildDate>Sat, 28 Aug 2010 12:01:22 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>By: Jeremy Cook</title><link>http://jeremycook.ca/2010/02/21/handling-binary-data-with-pdo/comment-page-1/#comment-11</link> <dc:creator>Jeremy Cook</dc:creator> <pubDate>Thu, 04 Mar 2010 20:58:19 +0000</pubDate> <guid isPermaLink="false">http://jeremycook.ca/?p=64#comment-11</guid> <description>In reply to Dennis: I think you have a very valid point but Josh&#039;s solution is the only one I&#039;ve seen so far that completely gets around this bug. For my purposes simply writing the binary data to the output was enough as all I needed to do was to display the image. For anything else I&#039;d probably need a stream, which is where Josh&#039;s solution comes in. I completely agree with you in that it&#039;s not optimal from a memory consumption point of view. The only true solution would be for this bug to be fixed I guess.</description> <content:encoded><![CDATA[<p>In reply to Dennis: I think you have a very valid point but Josh&#8217;s solution is the only one I&#8217;ve seen so far that completely gets around this bug. For my purposes simply writing the binary data to the output was enough as all I needed to do was to display the image. For anything else I&#8217;d probably need a stream, which is where Josh&#8217;s solution comes in. I completely agree with you in that it&#8217;s not optimal from a memory consumption point of view. The only true solution would be for this bug to be fixed I guess.</p> ]]></content:encoded> </item> <item><title>By: Dennis</title><link>http://jeremycook.ca/2010/02/21/handling-binary-data-with-pdo/comment-page-1/#comment-10</link> <dc:creator>Dennis</dc:creator> <pubDate>Thu, 04 Mar 2010 20:33:42 +0000</pubDate> <guid isPermaLink="false">http://jeremycook.ca/?p=64#comment-10</guid> <description>In reply to Josh: The whole idea of handling LOBs as streams is to greatly reduce memory load. While your workaround will work, it will keep the whole LOB in memory, and that LOB could be a few megs picture on a pretty busy site...</description> <content:encoded><![CDATA[<p>In reply to Josh: The whole idea of handling LOBs as streams is to greatly reduce memory load. While your workaround will work, it will keep the whole LOB in memory, and that LOB could be a few megs picture on a pretty busy site&#8230;</p> ]]></content:encoded> </item> <item><title>By: Dennis</title><link>http://jeremycook.ca/2010/02/21/handling-binary-data-with-pdo/comment-page-1/#comment-9</link> <dc:creator>Dennis</dc:creator> <pubDate>Thu, 04 Mar 2010 20:29:20 +0000</pubDate> <guid isPermaLink="false">http://jeremycook.ca/?p=64#comment-9</guid> <description>Yeah, this is a bit of shame that this bug is still around after three years. I reported it while writing my Learning PHP Data Objects book back in March 2007, and I am still very surprised it&#039;s not fixed.http://www.packtpub.com/Learning-PHP-Data-Objects-Open-Source/book</description> <content:encoded><![CDATA[<p>Yeah, this is a bit of shame that this bug is still around after three years. I reported it while writing my Learning PHP Data Objects book back in March 2007, and I am still very surprised it&#8217;s not fixed.</p><p><a href="http://www.packtpub.com/Learning-PHP-Data-Objects-Open-Source/book" rel="nofollow">http://www.packtpub.com/Learning-PHP-Data-Objects-Open-Source/book</a></p> ]]></content:encoded> </item> <item><title>By: abcphp.com</title><link>http://jeremycook.ca/2010/02/21/handling-binary-data-with-pdo/comment-page-1/#comment-8</link> <dc:creator>abcphp.com</dc:creator> <pubDate>Thu, 04 Mar 2010 10:45:00 +0000</pubDate> <guid isPermaLink="false">http://jeremycook.ca/?p=64#comment-8</guid> <description>&lt;strong&gt;Handling Binary Data with PDO...&lt;/strong&gt;I’m a great fan of the PDO database access library in PHP 5 and use it for all of my database work in PHP. I love its’ clean, object oriented syntax and great support for prepared statements. I also like the fact that it supports most of the most commo...</description> <content:encoded><![CDATA[<p><strong>Handling Binary Data with PDO&#8230;</strong></p><p>I’m a great fan of the PDO database access library in PHP 5 and use it for all of my database work in PHP. I love its’ clean, object oriented syntax and great support for prepared statements. I also like the fact that it supports most of the most commo&#8230;</p> ]]></content:encoded> </item> <item><title>By: Josh Johnston</title><link>http://jeremycook.ca/2010/02/21/handling-binary-data-with-pdo/comment-page-1/#comment-7</link> <dc:creator>Josh Johnston</dc:creator> <pubDate>Wed, 03 Mar 2010 22:30:22 +0000</pubDate> <guid isPermaLink="false">http://jeremycook.ca/?p=64#comment-7</guid> <description>You can also try this code to convert your string data into a stream first then continue accessing it as if it were a string. I haven&#039;t tested if the base64 data will output correctly or not but that is the basics of turning any in-memory data source into a stream[php] if (is_string($lob)) { // $lob is now a resource pointing to a stream composed of the data at hand $lob = fopen(&#039;data://text/plain;base64,&#039; . base64_encode($lob), &#039;r&#039;); }fpassthru($lob); [/php]</description> <content:encoded><![CDATA[<p>You can also try this code to convert your string data into a stream first then continue accessing it as if it were a string. I haven&#8217;t tested if the base64 data will output correctly or not but that is the basics of turning any in-memory data source into a stream</p><pre class="brush: php;">
if (is_string($lob)) {
   // $lob is now a resource pointing to a stream composed of the data at hand
   $lob = fopen('data://text/plain;base64,' . base64_encode($lob), 'r');
}

fpassthru($lob);
</pre>]]></content:encoded> </item> <item><title>By: Jeremy Cook&#8217;s Blog: Handling Binary Data with PDO &#124; Webs Developer</title><link>http://jeremycook.ca/2010/02/21/handling-binary-data-with-pdo/comment-page-1/#comment-5</link> <dc:creator>Jeremy Cook&#8217;s Blog: Handling Binary Data with PDO &#124; Webs Developer</dc:creator> <pubDate>Wed, 03 Mar 2010 22:08:07 +0000</pubDate> <guid isPermaLink="false">http://jeremycook.ca/?p=64#comment-5</guid> <description>[...] Cook has put together a quick guide for something that can be tricky when using PDO in PHP - handling binary data in the return from your queries.   I like the fact that if I needed to use MS SQL Server, Oracle or [...]</description> <content:encoded><![CDATA[<p>[...] Cook has put together a quick guide for something that can be tricky when using PDO in PHP &#8211; handling binary data in the return from your queries.   I like the fact that if I needed to use MS SQL Server, Oracle or [...]</p> ]]></content:encoded> </item> <item><title>By: Jeremy Cook&#8217;s Blog: Handling Binary Data with PDO &#124; Development Blog With Code Updates : Developercast.com</title><link>http://jeremycook.ca/2010/02/21/handling-binary-data-with-pdo/comment-page-1/#comment-4</link> <dc:creator>Jeremy Cook&#8217;s Blog: Handling Binary Data with PDO &#124; Development Blog With Code Updates : Developercast.com</dc:creator> <pubDate>Wed, 03 Mar 2010 21:36:22 +0000</pubDate> <guid isPermaLink="false">http://jeremycook.ca/?p=64#comment-4</guid> <description>[...] Cook has put together a quick guide for something that can be tricky when using PDO in PHP - handling binary data in the return from your queries.   I like the fact that if I needed to use MS SQL Server, Oracle or [...]</description> <content:encoded><![CDATA[<p>[...] Cook has put together a quick guide for something that can be tricky when using PDO in PHP &#8211; handling binary data in the return from your queries.   I like the fact that if I needed to use MS SQL Server, Oracle or [...]</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Database Caching using disk
Object Caching 416/418 objects using disk

Served from: jeremycook.ca @ 2010-09-08 22:16:33 -->