Haven’t updated the blog for a while so I thought I would create a few posts on what I have been up to in the early stages of 2009!
Back in February, I developed a microsite for Dr Martens, named ‘Dr Martens For Life’. The whole idea behind the site is to activate your guarantee for your Dr Martens Boots / Shoes for life!

Using CakePHP, I did some lovely custom validation to check if a guarantee code was valid (from a list of codes in a MySQL table) and also to see if it had not been redeemed before (only one code per product).
Take a look, if you fancy buying a pair of Dr Martens - take a look here too.
Posted in Web | No Comments »
Looking for a special gift for someone but cannot think of what?
Well shhh.tv is here to sort that!! simply, answer a few questions and generate a gift for a friend or foe… its a shhhhhecret!

shhh.tv is a MAKE project for LOVE.
I am proud to say that I built the ‘back-end’ of the site…. ooooh err, using the CakePHP framework, MySQL and AMFPHP.
Enjoy and Merry Christmas!
Posted in General, Web, Work | 1 Comment »

Been really busy at LOVE for the last couple of weeks (well all year to be honest!), working on numerous websites including the lovely Green Santa website.
Taken from the LOVE blog post: “The basic premise of Green Santa is simple:
Global warming is causing Santa’s runway to melt.
If Santa’s runway melts, his sleigh can’t take off.
If his sleigh can’t take off, he can’t deliver your Christmas presents.
So if you want your presents this year, you’ll need to do your bit for the environment first.”
There is also a Green Santa Facebook Application, if your a facebook user - please add the application to receive the lastest breaking news to your profile!
Visit Green Santa and make a pledge!
Posted in Web, Work | No Comments »

Last night LOVE were nominated for the “Freshest Digital Campaign” for the work carried out on Warburtons We Love Bread website.
I am glad to say we won! Well done to all those involved, including: Adam, Jim and Stu.
Posted in Awards, Work | 1 Comment »
I have just been refactoring a legacy database and needed to update some data in one table from another table in MySQL.
In this case the 2 tables had the same values for the identity colomn.
Syntax:
UPDATE tablename1 t1
SET colomn1 = (SELECT colomn1 from tablename2 t2 WHERE t1.id = t2.id);
For example
If i had tables: ‘products’ and ‘merchandise’ and needed to copy the product title into the merchandise title colomn, I would simply:
UPDATE merchandise m
SET title = (SELECT title from products p where m.id = p.id);
Posted in Databases | No Comments »
I have just been refactoring a legacy database and needed to copy some data from one table into a new table in MySQL.
Very easy task but very easily forgotten, just thought I would blog about it to help anyone searching for a quick answer…
Syntax:
INSERT INTO tablename (colomn1, colomn2 ...)
SELECT colomn1, colomn2 ...
FROM tablename;
For example
If i had a products table and needed to copy the product title into another table named ‘merchandise’ I would simply:
INSERT INTO merchandise (title)
SELECT title FROM products;
Posted in Databases | 6 Comments »

On Thursday night LOVE will be attending the Fresh Digital Awards 2008, unfortunately I won’t be there due to other commitments. We are nominated for 1 award - ‘Freshest Digital Campaign‘ for the work I was involved with for Warburtons ‘National Bread Week‘.
Here’s hoping that we scoop another award for this lovely website!
Posted in Awards, Work | No Comments »
Something I seem to do quite regularly at the moment is resetting the auto increment value for a table in a MySQL database.
Really easy to do but also very easy to forget the syntax:
ALTER TABLE tablename AUTO_INCREMENT = value;
For example
If I had a products table and I created a few new products and then deleted them, to set the auto increment value back to ‘53′ i would simply:
ALTER TABLE products AUTO_INCREMENT = 53;
Posted in Databases | 1 Comment »
CakePHP’s validation class is pretty powerful, however there may be a time when you require a validation method that hasn’t been defined, this is where custom validation rules fit in.
Lets imagine you have a select box containing a users ‘title’ field in a form. You also have a ‘other_title’ text field which must be filled in if the ‘Other’ value is selected.
How would you go about validating this?
Simple: In your Model specify your validation criteria as so…
var $validate = array(
'title' => array(
'rule' => array('minLength',1),
'message' => 'Please select your title'
),
'other_title' => array(
'rule' => array('_compareFields', 'title', 'other'),
'message' => 'Please enter your other title'
)
);
As you can see when the Model validates, the ‘other_title’ field is validated against a custom rule named ‘_compareFields’ parsing in ‘title’ and ‘other’ as parameters.
‘title’ is the field to compare ‘title_other’ with and ‘other’ is the compare value that I am matching on.
Therefore the custom rule looks like:
function _compareFields($field=array(), $compare_field, $compare_value){
if(!empty($this->data[$this->name][$compare_field])&&(strtolower($this->data[$this->name][$compare_field]) == strtolower($compare_value))) {
$field_value = array_shift($field);
if(!empty($field_value)) {
return true;
} else {
return false;
}
} else {
return true;
}
}
I could of simply used ‘Other’ as the $compare_value but I like writing generic functions that can be re-used multiple times. This function will now cater for other fields with different $compare_fields and the ‘case’ of this value is not sensitive in the view.
Hope that helps someone out there!
Posted in Web | 1 Comment »

Just returned from a nice 4 night stay in Rome with the missus. Rome is absolutely amazing! Saw all the sites, drank the beer, gawped at the cars, mixed in with the beautiful locals and saw some monkeys having rampant sex in the zoo… hmm
One of my favourite highlights of the trip was the Vatican City. The detailing on the dome was too much to take!

We managed to view not only the Vatican City, but also The Pantheon, Roman Forum, Villa Borghese, The Colosseum, Spanish Steps, Piazza Navona, Trevi Fountain, Capuchin Crypt and the Catacombs. So much to see in so little time….
Here are some snaps…
The Colosseum



Roman Forum

Villa Borghese



Posted in General | No Comments »