Quote 28

Life would be so much easier if we just had the source code.

— Unknown

Quote 27

As a programmer, I find your faith in computers amusing.

— Unknown

Quote 26

Computers are useless. They can only give you answers.

— Pablo Picasso

Simplifying SQL

Most PHP applications do fundamentally the same thing: Shuffle data from an SQL database to a web page and back again. The details vary with the application, but in general that's what most web apps do. That very quickly runs into the bane of most PHP developers' lives: SQL syntax.

It's not SQL syntax itself that is bad per se. The problem is that it is a string-serialized format, which means you have to take your nice clean data structures and serialize them out into a string that has no semantic meaning to your PHP application. That's boring, dull, and introduces all sorts of places to totally mess up your application with a typo, and that's without even touching on issues of security. And then there are the issues with SQL syntax itself, in particular the way in which INSERT and UPDATE statements, which seem like they should be similar, have no similarity whatsoever. That makes "replace" operations (insert if new or update if not) very tedious to write, particularly if you have a lot of fields.

Fortunately, with a little ingenuity and help from PHP's array handling, we can give ourselves a common syntax for INSERT and UPDATE operations that maintains semantic meaning, and then get DELETE statements free of charge. Let's see how.

Too much of an upstart

So it seems Ubuntu, a distribution I have grown to like more and more of late (especially every time something breaks in Debian Sid), has decided that init has got to go. Their answer? Not any of the various attempts to replace it in the past, but once again start from scratch with something called Upstart. While I agree that init is one of the many parts of typical GNU/Linux system that desperately needs to grow out of the 1970s, I'm not sure that Upstart is the right way to do it.

A blog reborn

As both of my avid readers have likely noticed, this blog has not been particularly active of late. That is to say, today is the one year anniversary of the last time it was actually used. :-) So what do I do to celebrate? Rebuild the whole thing from scratch, of course!

Quote 22

Doing it right is no excuse for not meeting the schedule.

— Plant Manager

Quote 21

Whoever is careless with truth in small matters cannot be trusted in important affairs.

— Albert Einstein

Quote 20

Fix a computer and it will break tomorrow. Teach its owner to fix it and it will break in some way you've never seen before.

— Unknown

Quote 19

Arguing with an engineer is like mud wrestling with a pig; after a few hours, you realize he likes it.

— Jamie Lawrence

Syndicate content