Tips of the Week

cakePHP saveall() and transactions, jQuery form plugin AJAX error handling

November 19, 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(); }

How to use a fallback AJAX failure mechanism

November 2, 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 [...]

Running cUrl on localhost can topple your router

October 27, 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.

Don’t install IE on Ubuntu 8.04

October 27, 2008

Its been a while since I’ve had anything to write about, and this isn’t much of a tip. But still. Everyone has had to test their site in different web browsers, everyone likely to read this anyway. Its a pain in the arse as we all know. What is worse, is trying to get IE [...]

CakePHP deployment errors

August 12, 2008

If you have set cakephp up so that DocumentRoot of apache is pointing to app/webroot/ you might have encountered a couple of errors like these – not the first time you set it up, but consequent attempts to remove and replace the files.

CakePHP redirect to admin methods

July 30, 2008
Thumbnail image for CakePHP redirect to admin methods

If you have admin routing set: Configure::write(’Routing.admin’, ‘admin’); Redirecting between admin_* and non admin functions inside the controller, or linking to admin_* functions from non admin views can throw an error unless you pass an admin variable in the URL.

Use iconv to help migrate databases

July 21, 2008

Iconv is a useful tool to convert the encoding of given files from one encoding to another – which comes in very handy if you want to migrate that old MySQL 4 database to a hot new MySQL 5. I recently had to migrate a database from MySQL 4 to 5 and its not as [...]

Javascript Dom Quirk In IE using getElementById

April 24, 2008

This is a fun one I found today – using getElementById() in IE7 to find a dom element on the page, if you are getting some interesting errors then one possibility is that you have two elements with the same id – or the same name attribute it seems.

Resize images in Ubuntu

April 9, 2008

Looking around for an easy way to resize my images ready for uploading to facebook. Sure, you can use gimp batch processes, but that looks like an awful lot of work. You could install Davids batch processor for Gimp. OR, you could do it the truly easy way with a single command:

Carriage Returns in PHP Plain Text Emails

April 3, 2008

Another quick tip for the archives. Carriage returns on lines in your view finishing with a php statement. Try sending these views as an email and somehow the resulting email does not look entirely correct. The carriage returns have not been passed through. This is a quick, hackish, tip so I really didn’t get to [...]