Updates from February, 2008 Toggle Comment Threads | Keyboard Shortcuts

  • Joe 12:19 on February 26, 2008 Permalink
    Tags: , finderQuery, , Nigel McNie, pagination, patch,   

    Using pagination with CakePHP’s finderQuery SQL 

    Cakephp 1.2

    Update February 2009: this article is now about a year old and deals with an early beta versions of CakePHP 1.2. In the mean time, CakePHP 1.2 has been released with many improvements and great documentation. Please don’t use this patch, use this instead. I’ll leave the article below for reference.

    Cakephp lets you define various kinds of associations between models. The principle is really simple, just define arrays like $hasMany in your main model, where associations with other models are defined.

    For most purposes this does the trick, most associations are made by convention, but you can override these as well for e.g. database (foreign-) keys.

    From there on, you can use all cake built-in functionality to retrieve model data. One such feature is auto pagination, where the page size is set through the value of the limit field in the model’s definition.

    If you’re crafting something really complex, you can define your own SQL query in the finderQuery field. This is very nice, but the trade-of is that the other fields are ignored in the query. And if fields limit and offset are ignored, you no longer get auto pagination.

    The patch below fixes this for the current development tree of CakePHP 1.2 (revision 6461).
    (More …)

  • Joe 13:43 on February 14, 2008 Permalink

    Cakephp: isAjax weirdness 

    Cakephp 1.2Currently, I’m doing a project in CakePHP.

    There’s lots to say about cake, here just a quick note, for myself or for anyone in case you are running into the same problem.

    Situation: you are using the Ajax helper, which contains a method isAjax() – returns true if the request was an Ajax request.

    Typically, you use this method inside a view, to conditionally render content for regular/ajax views. Example:

    if (! $ajax->isAjax()) {
    // render general page stuff
    // render stuff for both regular- and ajax view

    My problem was that the isAjax() call never returned true, regardless of ajax/regular request method.

    The solution appears to be really simple: you should include the 'RequestHandler' component in your controller class. This one took me way too long to figure out!

    public $components = array (

    Update my situation was even worse than described above; I use a redirect between controllers within an Ajax call, something which is officially supported by Cake 1.2. This worked just fine in Safari, but not in Firefox (and Opera) – these browsers would not load the Ajax view but rather the complete page, almost crashing the server by consuming huge amounts of memory.

    Read on… (More …)

  • Joe 22:17 on February 11, 2008 Permalink
    Tags: , , , update   

    OSX Updates! 

    Finally, the long awaited Leopard update is here, bringing the current Mac OSX version number to 10.5.2. Hopefully, a lot of annoyances of one of the worst OSX releases will have been fixed.

    It’s still too early to tell, I just upgraded a few minutes ago. First impressions are not bad, but I’m not seeing a lot of difference either.

    Other good news from the update front: only a few days or so ago, Shirt Pocket released their Leopard compatible update of SuperDuper! (see also my post on “Forced Features” in OSX).

    Feeling much more secure to upgrade OSX on a fully backed-up system, so reverting is as easy as attaching my external USB drive. I’m a happy camper now, let’s see the coming days…


Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc

Twitter links powered by Tweet This v1.8.3, a WordPress plugin for Twitter.