19
11
2008
cakePHP, saveAll() and Transactions
MySQL transactions and cakePHP, the two play nicely together. Its very easy to wrap your inserts and updates in transactions with cake:
Model->begin();
try {
if (!Model->save()) throw new Exception('Model did not save');
if (!Model->subModel->save()) throw new Exception('Sub Model did not save');
Model->commit();
}
catch (Exception $e) {
Model->rollback();
}
Read more…
17
11
2008
A simple method to paginate data seperately on a single page using the cakePHP paginator helper/object.
The Problem
In this case I want to paginate the news items, but I have a flag in the news item table for is_archive, so basically want to seperate the current news items from the archived ones and display both sets of data on the same page in two seperate tables. Then use cakePhp’s built in pagination to navigate through both sets of data independently of each other.
I used AJAX and the paginator options to get a very simple implementation working quite quickly.
Read more…
12
11
2008
I’m an identity theif.
I’ve been using the IRC channel for cakephp, jquery and others for a while now without a registered password, at first I thought I would just try it out, but as these IRC channels have become more and more handy it became time for me to register properly and stop impersonating someone else
I found the whole process slightly convoluted so here is the 1-10 of registering a nickname with Nickserv and joining an IRC channel using Pidgin on Ubuntu.
Read more…
2
11
2008
I’ve found using one default fallback AJAX failure mechanism to be a bit of a life saver, it would prove even more useful if you are making a lot of AJAX calls distributed across your site.
I found this approach especially helpful in controlling when the AJAX failure callback is triggered, so you don’t end up in messy situaitons where your controller processes the request and the wrong view is sent back to your AJAX success callback.
Read more…
27
10
2008
I tell a lie. In my last post moments ago I stated: ‘I don’t have any tips right now.’ Forgetting this little beaut.
Read more…