MainelyDesign.com Blog

Habtm Tagged Blog Posts

Forcing A Single Join in CakePHP Pagination

Posted on 10/14/2011 at 09:25 am | Viewed 22,644 times | 0 comments

The devil's in the details... I was trying to make a really simple, dreadfully easy, database join in my CakePHP web application.  I've forced joins in Cake before, using the 'joins' key in the options array for find calls and paginate calls with no issue.  It was late and for the first time I only wanted to use a single join.  I copied the join code from a much more complex web app and pasted it into my new 'joins' conditions.  And then... I got SQL errors. 

Best PaginateCount for CakePHP - with Group By Support

Posted on 08/07/2011 at 05:03 pm | Viewed 20,045 times | 0 comments

I'm been muddling my way through pagination with multiple joins, and complex filtering.  I finally got it all working (more on that later, maybe....) when I noticed that I couldn't paginate my results.  Everything was working fine until I added a "group" parameter to the find call.  Instead of getting the right count, I got a count of 1!  A quick look at my sql log tables (at the bottom of the page) and I saw that I had actually returned all the mysql records that were needed!  If only there was a way to use them...

saveAll() to save multiple records in 1 model

Posted on 04/17/2009 at 09:58 am | Viewed 18,946 times | 0 comments

I ran into another issue on something I thought would be simple: saving multiple records with the saveAll() command.  In case you don't know about it, saveAll() is one of the best functions in CakePHP.  It automatically supports transactions, HABTM saves, and certainly saves a lot of typing for almost every type of save you want to do.

Full Tag List

Meet Site Avenger - Hosted Content Management System

Powered By: Site Avenger | Site Production: Saco Design