Development

1 minute read Published:

I’m just Git’ting it

Everyone and their mom have been using Git and GitHub for a while, but I’m just breaking down and using it… I have been slow to adopt because SVN worked for me fine (until I had to merge branches) and I don’t like to pay for storage space. But I continue to be impressed by it’s functionality and ease of use, so I’m going to move our work repositories over (needing a Large account probably) but I think it will be worth it.

1 minute read Published:

CakePHP beforeSave() gotcha: need to set $this->__exists to true if setting a primary key

I added an update to CakePHP Book: beforeSave() Also, if you add a primary key which would turn an “insert” into an “update” within beforeSave() you’ll need to set $this->__exists = true;… the call to $this->exists(); happens in model.php before the callback to beforeSave(). function beforeSave() { if (!isset($this->data[$this->name]['id']) && isset($this->data[$this->name]['unique_field'])) { $found = $this->find("first",array( "recursive" => -1, "fields" => array("id"), "conditions" => array("unique_field" => $this->data[$this->name]['unique_field']))); if (!empty($found) && isset($found[$this->name]['id'])) { $this->id = $this->data[$this->name]['id'] = $found[$this->name]['id']; $this->__exists = true; } } return parent::beforeSave(); } That’s been confusing me a bit recently – setting the ID of a row within beforesave() should change the save to an update, but it was trying to insert with a specified ID and thus, failing… glad to have a simple solution that makes sense… hope that helps someone else…

1 minute read Published:

MySQL Master/Slave Replication Monitoring PHP Script

I’m a bit proud of myself on this one… I setup a simple, but clean and configurable, MySQL Master/Slave Replication Monitoring PHP Script: http://code.google.com/p/php-mysql-master-slave-replication-monitor/ (docs) It’s Open Source and free, I welcome comments, suggestions, and questions. I think this will be quite useful for anyone who is setting up a pair of MySQL servers as master/slave and want to be sure their replication works as it should.

4 minute read Published:

SVN Merge, making sure a branch is updated from trunk, then merging back to trunk

So I’ve just fought a battle w/ SVN merge and thought I’d post the solution in case others might find it… Scenario Our stable code is in trunk svn://svn.domain.tld/repository/trunk I’ve got a branch of trunk svn://svn.domain.tld/repository/branches/dev Changes have been made to my branch and changes have been made to trunk, since I branched. I’m ready to merge my branch back into trunk. Approach / Overview Basically, to be safe, I need to first update my branch with the changes from trunk and resolve any conflicts.

1 minute read Published:

Mantis to Basecamp to-do(s)

I just created a handy little script to create todos in basecamp for unresovled tickets in mantis. You can see the open sourced code/project: http://code.google.com/p/mantis2basecamp-todo/. This is something we found useful, if you use both tools, you might find it useful as well.