Posts tagged with 'doctrine'

Doctrine article in php|architect

Ah, fame at last!

Cover of php|architect

The latest issue

It looks like the new issue of php|architect is out, and contains my article about Doctrine, the PHP-based Object Relational Mapper.

It feels like ages since I wrote it (I'm no longer a 'freelance PHP developer' for a start) so re-reading it was actually a slightly weird experience.

It's my first published work, and I'm fairly happy with it. Hopefully I'll get another chance to write for php|architect, I just need to think of another subject that I have something to say about.

The bad news for most of you cheapskates is that php|architect is a subscription-only publication so you can't read my article for free! However, I would genuinely recommend the magazine, especially as it's only effectively $2.50/issue. Obviously I wouldn't recommend it for people who aren't interested in PHP, however!

Simplify pagination logic using a custom Zend_Paginator_Adapter

Pagination logic is something that I've found myself redoing a number of times over the years, and each time it's been a relatively fiddly and painful process.

This time around I decided to check out the Zend_Paginator component from the Zend Framework, and found the process useful enough to share! In my case I was using Doctrine to retrieve data from the database. I'll skip most of the Doctrine-specific stuff, however, as hopefully this will end up as a decent example of how to integrate Paginator with other non-Zend libraries.

When the Paginator is instanced, it's given an instance of an appropriate Adapter and told what the current page is:

<?php
$paginator 
=  new Zend_Paginator($adapter);
$paginator->setItemCountPerPage(20);
$paginator->setCurrentPageNumber(2);