News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Paul Jones' Blog:
New PDO Behavior In PHP 5.2.1
February 28, 2007 @ 08:29:00

http://www.phpdeveloper.org/form/view/type/addnews PHPDeveloper.org: PHP News, Views, and Community In a new post Paul Jones points out some of the new behaviors that the extension is showing in the latest of the PHP 5 seres (version 5.2).

He starts with a code example that would work with a previous version of PHP/PDO that would allow for the binding of a single value to multiple places in the SQL statement. But:

Sadly, this is no longer the case in PHP 5.2.1. For valid reasons of security and stability in memory handling, as noted to me by Wez Furlong, the above behavior is no longer supported. That is, you cannot bind a single parameter or value to multiple identical placeholders in a statement. If you try it, PDO will throw an exception or raise an error, and will not execute the query. In short, you now need to match exactly the number of bound parameters or values with the number of placeholders.

Unfortunately, this is used quite often in Paul's Solar framework, so an update to the Solar_Sql_Adapter::query() method has had to been made to allow for the binding of multiple items automatically. It works by incrementing the bind location (like ":foo") with numbers at the end - simple and effective - and you can still pass an array to it and have it automagically work.

1 comment voice your opinion now!
pdo php5 behavior bind variable multiple array placeholder increment pdo php5 behavior bind variable multiple array placeholder increment


blog comments powered by Disqus

Similar Posts

David Sklar\'s Blog: Two New O\'Reilly PHP Translations

HowTo Forge: How To Harden PHP5 With Suhosin On Fedora 7

Zend Developer Zone: Paging Data Sets With PEAR Pager

Gennady Feldman's Blog: Migration to PHP5 links and articles

DevShed: PHP 5 and Polymorphism


Community Events

Don't see your event here?
Let us know!


opinion community example conference laravel series framework language library configure interview podcast symfony2 php7 performance voicesoftheelephpant application api release introduction

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework