phup 'n stuff

Another Blog About Being a Developer

Archive for February, 2010

Omitting the Closing tag in PHP Files

Wednesday, February 24th, 2010

At first when I saw the Zend Framework recommendation of omitting the closing tag in PHP files I thought it bizarre and stupid. Afterall, you close every other syntactic character in programming: parenthesis, brackets, HTML tags, ifs, loops, etc. So why wouldn't you close the PHP tag at the end of the document as well?

The Zend Framework reason is, of course, to white space data from being sent to the browser prematurely, which messes up sending header information to the browser. My first thought was "this is lazy and encourages bad coding."

But the more I think about it, the more it makes sense. It isn't laziness, but a fool proof way to prevent a common mistake from happening. And apparently the closing tag isn't required at all, so why not?

I don't think I'll be quick to adopt this practice, but maybe eventually, and maybe as I write new code. We'll see.

MySQL and the Most Useless Feature Ever

Wednesday, February 24th, 2010

While building MySQL database support into the OpenAvanti PHP framework, I came across an interesting quirk in MySQL that I thought must be a bug. Apparently, after submitting a bug report and getting a response from MySQL, it's a documented feature (and later, referred to as a limitation).

(more…)

An Epic Struggle With Portage

Tuesday, February 23rd, 2010

Today I embarked on an epic struggle with the Portage package manager attempting to update the packages on my system. After I ran into what can only be described as a phantom package.

(more…)

array_to_string in PostgreSQL

Wednesday, February 17th, 2010

This snippet courtesy of Kieran Smith.

Want to get more work done in a single query? Tired of looping through query results to simply build a list of data. How about this?

SELECT
array_to_string(
    ARRAY(
        SELECT name
        FROM projects
        WHERE customer_id = 10
        ORDER BY LOWER(name)
    ), ', '
) AS projects;

What you are doing is building an array from the subquery and then turning it back into a string immediately, so you can display multiple results in a single field. Our results might look something like this:

gnucashweb, Hangar, OpenAvanti, tarmac

Nice!

Gentoo Portage Alternative

Tuesday, February 2nd, 2010

I just came across an alternative to the http://gentoo-portage.com and http://packages.gentoo.org sites: http://znurt.org/

Nice, clean, beautiful and full of information.