PHP Zend Framework

Database Profiling with Zend Db Profiler Firebug

I don’t know why I haven’t been using this for ages. But Zend’s DB Profiler is fun. Only to be used in development so you can see what your database is doing and how fast/slow it’s doing it.

Enable it in your application’s config.ini (or .xml)

db.profiler.enabled = true
db.profiler.class   = "Zend_Db_Profiler_Firebug"

And as long as you’re using the DB Factory to create your connection, everything that happens will be automatically profiled and spewed out via Firebug’s awesome logging.  It shows you time spent, number of queries, the queries themselves and parameters used.  It’s awesome.  Why haven’t I been using this before?

You can also enable it directly on your database object if you don’t want it in your config; for example I have block of code that runs only when debugging is enabled (development environment) and as such I might want to enable the profiler there:

       array('enabled' => true, 'class' => "Zend_Db_Profiler_Firebug"));

Yeah, it’s awesome.


It’s alive: Moments Like Today

It’s finally alive!

You can read Magaret’s announcement here.

What it is:

‘Moments Like Today’ is a collaborative project that aims to inspire people to post “moments” of their lives in three sections: mornings, afternoons, and evenings.

What I did:

While the concept and design came from Margaret and Myra, the functionality and everything back-end came from me.  With some zend framework, some man-handling of APIs from Flickr and Vimeo and a little bit of jQuery fun, the end result (for now)  is live.

If you’d like to participate in the project you can visit the Moments Like Today and read the how-to for more information.


Adding an Auto Increment Column After The Fact…

Yep, I pulled a ‘whoops’ today. I made a table, filled it with data, then realized I forgot my standard ‘id’.  My primary key, auto incrementing column that makes me feel good about myself.

Once I noticed it was gone, it was easy to add it back. Right? Right? Well, not so fast.  You can add the new column at the beginning of the table.  But as soon as you go to set it to a Primary, Auto increment, MySQL is going to cry because of all the zero values.  The primary key’s can’t be the same so it blows up.

Before setting it to be the primary key, you need to auto-fill it.  You can do it programmatically with any script of your choice, but I find it easy to do it with MySQL…

SET @pants := 0;
UPDATE `ratings` SET id = (SELECT @pants := @pants + 1);

And that’s it.  Time for a beer.


Summer Project: Initial Setup and more Details

I’m still chugging along with the common elements on the project.

So, for the basics of what I have decided to do: Yep, it’s an image gallery.  It’s not too exciting and definitely nothing original.  There’ll be a basic authentication system (login/logout) with web based uploading and tagging.  That’s pretty much it.  The images that get uploaded will be stored in the database itself as a nice central location for all my different variants to get the data from.

As far as the initial setup goes, I’ve managed to get PostgreSQL installed, running, and I’ve even created the necessary tables for all that I need.  Yeah, that part was pretty simple.  But I can’t say it happened without learning something.  I’ve noticed that something I took for granted with MySQL wasn’t available right away for my installation of PostgreSQL.

Coding MySQL Ubuntu

Summer Project: Setup PostgreSQL

Using my shiny new upgraded Ubuntu 9.04, I’ve gotten around to installing PostgreSQL.

Note: this is not a tutorial.

The installation was simple, as are most installations with Ubuntu. The initial “get going” was a bit odd for PostgreSQL though. The one thing you have to remember when initially trying to get things going is this…

MySQL Ubuntu

Ubuntu, AppArmour, and Moving MySQL Data

Note to self, when moving the path where mysql stores it’s files, make sure you edit the App Armour file to allow mysqld to write to the new location.

Time wasted: 30 minutes.

The message:

kernel: [422118.789696] audit(1233167081.635:38): type=1503 operation="inode_create"
requested_mask="w::" denied_mask="w::" name="/opt/mysql/pluto.lower-test"
pid=12412 profile="/usr/sbin/mysqld" namespace="default"

The solution: edit this file;


And add the necessary new paths… Good times, right there.