Welcome to MainelyDesign.com

Photos of Rockland, Maine. Summer 2009.

A blog mostly about web design

This is the personal blog of Kevin Wentworth.  Topics covered here are web programming, design and internet marketing.

Forcing A Single Join in CakePHP Pagination

Posted on 10/14/2011 at 09:25 am | Viewed 750 times | 5 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. 

Inserting NOW() into MySQL Using CakePHP

Posted on 08/11/2011 at 11:16 pm | Viewed 702 times | 0 comments

Great find.  If you want to insert NOW() into your query using CakePHP's save() or saveAll() functions, you can use the following expression:

Best PaginateCount for CakePHP - with Group By Support

Posted on 08/07/2011 at 05:03 pm | Viewed 870 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...

CakePHP Error Messages Not Showing on Form

Posted on 04/03/2011 at 12:40 pm | Viewed 2,199 times | 2 comments

I ran into an issue today that I've run into before, except I couldn't remember what I did to fix it (hence this article).  I was using CakePHP validation rules to validate a user account details.  The CakePHP validation was properly failing (the form data wasn't being saved) and I could tell the validate array was set correctly because the required fields were having the class .required added to them.  The only problem?  No error messages were being output to the form.  The form validation would fail, but the CakePHP error messages were not being shown.

Sorting Paginated Results Using a Related Model Field in CakePHP

Posted on 02/06/2011 at 10:12 pm | Viewed 2,466 times | 0 comments

Time crunch, so this will be quick.  I didn't want to go hunting for how to sort paginated results in CakePHP using a related model field again.  I actually found my answer on Stack Overflow.  The original poster had it right, so I'm not sure if it was a CakePHP bug or what (I don't have an account or I would correct it... it's on the list of to-dos though).

Read More Posts.

Meet Site Avenger - Hosted Content Management System

Powered By: Site Avenger | Site Production: Saco Design