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
Dec 21, 2010 @ 19: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.

tagged: zenddb in clause bind variable array zendframework

Link:

DevShed:
Utilizing the LIMIT Clause with the Active Record Pattern
Mar 31, 2009 @ 17:58:35

DevShed continues their series on the Active Record pattern in PHP with this new article implementing the LIMIT statement on your abstraction class.

In its current version, it'll be able to accomplish only a few basic database operations tasks. Therefore, this fifth article of the series will be focused on enabling the class to fetch database rows by using the LIMIT clause.

They add the LIMIT clause as a part of its own function and its own SQL statement. You define the number of rows to fetch, the table to fetch it from and the offset to start from. The SQL is passed off to their fetchRow statement and the results are returned in an array.

tagged: activerecord design pattern clause limit abstraction layer database

Link:

DevShed:
The LIKE Clause and the Active Record Pattern
Mar 24, 2009 @ 17:07:39

DevShed continues their look at the Active Record pattern with the next part of their seven part series - extending their MySQL class even further.

In its current incarnation, this class's functionality is limited, regardless of its decent level of SQL abstraction. Therefore, in this fourth part of the series I’m going to enhance it by making it capable of working with LIKE clauses in a straightforward way.

They look at using LIKE to match values in various columns of the tables and add in a fetchLike method that lets you specify the column to search, the pattern to match on and the table to search in.

tagged: like clause tutorial activerecord pattern designpattern fetchlike

Link:

Chris Shiflett's Blog:
Zend Framework License
Apr 26, 2006 @ 20:46:59

Chris Shiflett has some good news for all of the Zend Framework fans out there - the license that it's under is now compatible with the GPL.

This means you can use the ZF for your own GPL-licensed PHP project. The big change is the removal of the advertising clause: 'Redistributions of any form whatsoever must retain the following acknowledgment: "This product includes the Zend Framework, freely available at http://www.zend.com/"'

Chris notes also that it's a welcome change over to this pre-existing license to reduce the number of licenses that companies would have to change/evaluate.

tagged: zend framework license gpl compatible advertising clause zend framework license gpl compatible advertising clause

Link:

Chris Shiflett's Blog:
Zend Framework License
Apr 26, 2006 @ 20:46:59

Chris Shiflett has some good news for all of the Zend Framework fans out there - the license that it's under is now compatible with the GPL.

This means you can use the ZF for your own GPL-licensed PHP project. The big change is the removal of the advertising clause: 'Redistributions of any form whatsoever must retain the following acknowledgment: "This product includes the Zend Framework, freely available at http://www.zend.com/"'

Chris notes also that it's a welcome change over to this pre-existing license to reduce the number of licenses that companies would have to change/evaluate.

tagged: zend framework license gpl compatible advertising clause zend framework license gpl compatible advertising clause

Link:


Trending Topics: