call_user_func(_array) behaviour in PHP 5.3

Before PHP 5.3 you could use call_user_func and call_user_func_array even if you didnt provide an array with parameters. Since 5.3, this results in a ‘NULL’ without actually executing this method/function.

// works in < 5.3, but fails in > 5.3
$moduleItems = call_user_func_array(array($className, ‘getByTag’), $this->id);

// works everywhere
$moduleItems = call_user_func(array($className, ‘getByTag’), $this->id);

In all honesty, it’s normal that it shouldn’t work when you don’t provide the right parameters. However a decent notice would let me know that something is wrong.

Strange mysql sorting behaviour with enums

If you have an ENUM(‘Y’,'N’) field and you want to sort ASC on this field, mysql will show the Y values before the N values. It seems this is based on the order you defined them when creating your table… See the screenshot.

I’d like to add the explanation from which can be found here.

ENUM values are sorted according to the order in which the enumeration members were listed in the column specification. (In other words, ENUM values are sorted according to their index numbers.) For example, ‘a’  sorts before ‘b’ for ENUM(‘a’, ‘b’), but ‘b’ sorts before ‘a’ for ENUM(‘b’, ‘a’). The empty string sorts before nonempty strings, and NULL values sort before all other enumeration values. To prevent unexpected results, specify the ENUM list in alphabetic order.

Midas, hoofdpijn zonder zorgen

Aan die klootzakken die een camion uitlaten moesten lossen om 03u45 vannacht bij Midas (aan de achterkant van mijn appartement):

Vraag de code van het alarm zodat je de hele buurt niet moet wakkermaken. Dank bij voorbaat!

Jquery focus on first visual input element

I wanted the first visual form element, not having the noFocus class, get the focus when the page loads

$(‘form input:visible:not(.noFocus):first’).focus();

I love jquery!

Sennheiser in-ears

Sinds ik de Sennheiser cx400-II oordopjes heb, ben ik een gelukkige mens. Zelfs op standje 2 van mijn volume hoor ik niets meer van achtergrond geluid. De prijs van om en bij de 70 euro is natuurlijk wel andere koek.

Spoon Library – Form example

Check out the form example.

Spoon Library v1.2 released

A few days ago I released v1.2 for Spoon Library. Quite a few changes for this release.

Setting your timezone in mysql

If you want to set your timezone in mysql for your database connection, do this.

SET time_zone = ‘+2:00′;

Keep in mind that the number should be correct and can also have a minus sign, based on the timezone you want to set ofcourse. Do watch out for the UTC timezone, because mysql requires the +.

SET time_zone = ‘+0:00′;

Only 1 person writing PHP shizzle.

If I may believe my Google Reader, there’s only a handful of people that’s actually writing something decent about PHP. And as you might expect a shitload of websites tends to refer to that one persons’ posts, clouding my RSS feed with a bunch of nonsense. I love sundays.

Type hinting for objects

In Spoon I fetch my form elements in this way that it’s impossible for the library to provide the correct type hinting. You can fix this yourself by doing:

/* @var $txtEmail SpoonTextField */
$txtEmail = $this->frm->getField(‘email’);