..check it out the Foldi blog for updates on work, clients, etc...

Archive for the ‘CakePHP’ Category


Paginating results from multiple tables using CakePHP

Tuesday, December 29th, 2009

What you get from the CakePHP pagination helper is reason enough to use the CakePHP framework. However, what happens if you need to paginate results from multiple tables? I’ve set up a working demo to show an approach and have provided project files for download. In the app folder of the project files you’ll find a paginatedjoins.sql file to set up your tables. Remember to provide your own credentials in your config/database.php file.

(more…)

Queries across multiple databases with CakePHP

Friday, November 27th, 2009

Most CakePHP documentation assumes you’ll be working with tables in the same database. However, how do you query related data when your tables are spread across multiple databases? Fortunately, CakePHP makes this a breeze with the CakePHP model’s ‘useDbConfig’ variable and a little table prefix manipulation I picked up from this post in the CakePHP Google group.

Before the detailed explanation, you can view a working demo. Please note, this demo assumes you have basic knowledge of Cake models and associations.

(more…)

Basic search with CakePHP Part 2 – search criteria

Sunday, June 28th, 2009

This is part 2 of the Basic search with CakePHP where we’ll present the search criteria in a more user-friendly way. The files here build on part 1.

Here’s the working example.

(more…)

How to not lose URL params on form validation errors with CakePHP

Friday, June 26th, 2009

This problem makes me crazy every time I run into it. And the thing is, I know I’ve fixed it before and can never remember how. So I’m making this post as much for me as anyone else who may be stuck with losing URL parameters when a validation error occurs on a form.

Here’s a working demo.

(more…)

Basic search with CakePHP Part 1 – HABTM, joins and pagination

Wednesday, June 17th, 2009

This will be a multi-part demonstration for building basic search functionality using CakePHP. Part 1 focuses on searching across models that have HasAndBelongsToMany relationships. Here’s a working demo of Part 1.

You see this type of search when looking for items that share similar properties. In the demo, it’s Bars that have Features (WiFi, TV, etc), Scenes (Lounge, Afterhours, etc) and Neighborhoods (Chelsea, Soho, etc). HABTM search is also useful for searching items that share Tags, Colors, Size, Flavor and on and on.

(more…)