Zend Framework

Creating dynamic finders for Zend Db Table

I don't have to tell you that programmers are lazy.
That's why we love DRY (Don't Repeat Yourself).
If you find yourself creating lots of methods like findByName or findByTitle etc., you're going love what I'm about to show you.
With the dynamic finders you can use the following methods out of the box (ofcourse you'll have to extend your DbTable class to it).
- findByX('valueX')
- findLikeX('ValueX')
- findByXAndY('ValueX', 'ValueY')
- findLikeXAndY('ValueX', 'ValueY')
- findAllByX('valueX')
- findAllLikeX('valueX')

Using different databases with Zend Framework MultiDb

We can use Zend multiDb resource to connect to multiple databases.
We'll need 1 default database adapter or it will fail. Also I like having the profiler with the FireBug console during testing, so you can set it to true if you want.

Subscribe to RSS - Zend Framework