Technical Thoughts, Tutorials, and Musings

POTM February: Firebug

So February was an interesting month in my world, so interesting that it's now March and I didn't get around to posting a Project of the Month for February. Well, better late than never I suppose. To parallel GBGames' February Project of the Month, here's a big thank you cheer to my favorite Firefox extension and every web developer's best friend, Firebug.

Going to DrupalCon

Well, it's official. After being around Drupaldom for a year and a half now, I'll finally be making it to a DrupalCon. Yay! More specifically, the Open Source-CMS Summit, hosted by Yahoo (employer of such people as Rasmus Lerdorf), which will include DrupalCon. Drupal folks, I'll see you there (hopefully)!

Web 2.0 in Web 2.0

I normally don't post random "hey this is cool" posts, but this one really is that cool. The second video isn't all that great, giving more of a business talk, but the first one is slick, cool, insightful, and elegant. (About 5 minutes each.) Web 2.0 explained using Web 2.0. Nice!

Project of the Month: Drupal Project.module

Well here it is half-way through January and I've not made a POTM post yet. Bad Larry! Well, no time like the present. And the first present goes to a sub-project within Drupal that gets far less respect than it should. In fact, it's the sub-project that makes other sub-projects possible: The Project Module.

Sweet 16

When is Unicode not Unicode? When it's UTF-16 instead of UTF-8. Both are properly Unicode character sets, but for reasons that escape me they are not fully compatible. In today's installment of "Fix Microsoft's bugs", we'll look at how to deal with that little problem.

MVC vs. PAC

One of the most common mistakes I see people make when talking about web architecture is with regards to MVC. Generally it comes down to a statement such as this:

It's a web app, so we have to use MVC. That way we separate the logic and presentation, which means keeping PHP out of our display layer. All the important projects do it that way.

Of course, such a statement is false. It demonstrates a lack of understanding about MVC, about web applications, about "important projects", and about software architecture in general. Let's try to clarify, with a little help from Wikipedia.

Project of the Month

There are two things that tend to happen at the end of the year: Predictions about what the new year will hold that never come true, and new years resolutions that last until Martin Luther King Jr.'s Birthday. I'm not going to spend time on the first (at least this year), and I'm not going to be so lame and predictable as to call this a resolution so I avoid the curse of the second. That said, though, I am going to do something for the new year, and ask others to join me.

Announcing the Open Source Project of the Month!

More on Stupid Quotes

In an earlier entry I talked about different character encodings and how Microsoft manages to break the rest of the world with theirs. Thanks to a chance reading of a SitePoint forum post, I have a little more information on the problem. At least now it has a proper name.

PHP Group By with Arrays

By far the most common idiom when using SQL from a web application (PHP or otherwise) is simply listing records. The standard logic looks something like this (give or take real templating):

<?php
$result
= mysql_query("SELECT tid, name, size, color FROM things ORDER BY name, size");
print
"<table>\n";
print
"<tr><th>Name</th> <th>Size</th> <th>Color</th></tr>\n";
while (
$record = mysql_fetch_object($result)) {
  print
"<tr>\n";
  print
"<td><a href='viewthing.php?tid={$record->tid}'>{$record->name}</a></td>\n";
  print
"<td>{$record->size}</td>\n";
  print
"<td>{$record->color}</td>\n";
  print
"</tr>\n";
}
print
"</table>\n";
?>

That's all well and good, but in practice can be quite limiting. Why? Because you can't then group records, that is, display not one but several tables, one for each color. SQL, of course, offers a GROUP BY clause. That doesn't do what we want, however. GROUP BY is an aggregate clause, and is used for creating totals and summaries of records. We want to cluster records by a field that is not the ordering field, or a value that is calculated off of the record itself.

I've generally used two different methods for PHP-side grouping, one of them much cleaner and more flexible at the cost of a little performance.

What is your accent?

So apparently I don't have an accent. The InterWeb said it, so it must be true!

Syndicate content