News Feed
Sections




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

Till Klampaeckel's Blog:
Zend Framework Writing an IN-Clause with Zend_Db
December 21, 2010 @ 13:16:07

In a new post to his blog Till Klampaeckel looks at something the Zend Framework's Zend_Db component dosen't seem to support - an "IN" on a fetchAll - and how he worked around it.

The IN-clause is only supported when I wrap my statement with Zend_Db_Select, which is something I rarely do. Part of the reason is that I still don't feel comfortable writing my SQL in a DSL which doesn't really do anything besides wrapping a string into an object and IMHO it doesn't add to readability either. And the other reason is that I don't plan to run this import against any other database than MySQL. Which is why I don't see the need for abstraction either.

He shows some failing code where the IN isn't populated correctly when an array is passed in and the warnings that come with it. He solution's pretty simple, though - rewrite the query string before sending it with the correct number of bind locations ("?") for the number of parameters. In the comments, other approaches are suggested including using a simple select() call or tricking the bindings with a special kind of array.

0 comments voice your opinion now!
zenddb in clause bind variable array zendframework


blog comments powered by Disqus

Similar Posts

Matthew Weier O'Phinney's Blog: Model Infrastructure

Zend Developer Zone: PHP Abstract Podcast Episode 15: The Zend Access Control List

Pádraic Brady's Blog: Complex Views with the Zend Framework - Part 6: Setting The Terminology

Gergely Hodicska's Blog: Extending Zend_Acl to support custom roles and resources

Community News: Zend Framework 1.0.0 RC3 Released


Community Events

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


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

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