News Feed
Sections




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

Michael Nitschinger's Blog:
Custom Finders with Lithium
June 03, 2011 @ 09:03:25

Michael Nitschinger has another post that'll interest the Lithium framework users out there - how to create custom finders to help in code reuse for database requests.

Finders assist you with often-used database queries so you don't have to write them over and over again. Out of the box, Lithium provides you with a bunch of them: all, first, count list and "magic finders like" findById or findFirstById. How these are constructed in the core is not relevant for now, but Lithium provides you with a mechanism to write your own finders easily.

He starts with a look at the bundled finder, showing how it uses a _findFilters method to create the default filter and pass it into your configuration. He covers the parameters you'll need to define and an example of making a Task to create a new one. His example sets a limit of five results on the response. He also mentions the ability to add a custom finder to your model, loaded in the _init() automatically.

0 comments voice your opinion now!
custom finder lithium tutorial database


blog comments powered by Disqus

Similar Posts

O\'Reilly: Digg PHP\'s Scalability and Performance

Hasin Hayder's Blog: Using OAuth PECL Extension to Talk to Twitter

DevShed: Updating and Deleting Database Records with the Active Record Pattern

PHPMaster.com: The Need for Speed: Profiling with XHProf and XHGui

Evert Pot's Blog: Creating Streams from Strings in PHP


Community Events





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


opinion podcast security library tool interview list artisanfiles version framework series introduction symfony conference language composer laravel community voicesoftheelephpant release

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