A CakePHP gotcha for migrating from 1.1 to 1.2+ on Model->create()

I reported this as a ticket, but as it turns out, it’s a design choice.. but it’s enough of a gotcha that I thought I should report it.

What happened

The $this->ModelName->create() set the defaults for the next save, which is what I would expect. But on my database there’s a default value set for the ‘created’ field (the standard for datetime columns in PHPmyAdmin) as well as the ‘modified’ and ‘updated’ fields.
So when the $this->ModelName->create() function ran, it populated the ‘created’ and ‘updated’ and ‘modified’ fields based on their default values in MySQL; which is “0000-00-00 00:00:00″.
Subsequently, when I ran $this->ModelName->save($dataWithoutCreated); the ‘created’ and ‘updated’ and ‘modified’ fields were not defaulting to the current timestamp when they were not set by the $data passed into save… since they already had a “valid” value.

The Solution

Of course you can modify your model with a beforeSave() code to strip those off, but the “real” solution recommended by Mark Story is to change the default value of those fields in the database to NULL. This is something that sounded foreign to me, since PHPMyAdmin defaults to “0000-00-00″ for date/time fields, but it seems to work fine and I usually will defer to recommendations of the CakePHP core devs (and usually am happy I’ve done so).

Autosearch Craigslist with Google Alerts

Sometimes, I want something only if it’s on the cheap, second hand, and easy… that’s usually Craigslist.

Often what I want isn’t available when I think of it… but it might show up sometime… I don’t want to have to look at craigslist every day (because I wont).

Google Alerts to the rescue.

If I’m in Louisville KY and I’m looking for an iPod (for example) I just setup an alert for: “site:louisville.craigslist.org ipod”

Of course, that might be too many results and flood the inbox, but for the more obscure items, it’s a wonderful tactic and tool.

A Month of Site-Downtime

So the website has been down from Oct 21st to Nov 23rd.  The old server got hacked (or really, a sister-server) and due to security concerns, we didn’t know what got owned and what was safe.  We already had a different server hardware to put in place, just had to set it up.  So we got that installed and up and running, but it took me a few more days to get around to implementing something on my site.

I’ve switched to a WordPress controlled homepage, and I think I’m going to abandon the wiki (as opposed to simply not posting anything in it).

That is all…