First Aid license

Logo Het Vlaamse KruisFrom September 2009 till March 2010 I followed a First Aid course from Het Vlaamse Kruis in Grimbergen. After 2 exams (one for the basic first aid, and one for advanced first aid), I received my diploma yesterday at the city hall of Grimbergen.

Thanks to all the volunteers for all their time in preparing the course! It was very interesting, and I had a lot of fun!

Edit: I found some articles from news websites:

jQuery UI 1.8

I love to work with jQuery. It’s very easy to learn, and it’s so much fun to create applications, effects, Ajax, etc with it.

Next to jQuery, there is the jQuery UI. This user interface has not a lot of features like ExtJS, but the newest version (1.8) has already become a lot better.

The best new feature is the localization. In my last project it was a real struggle to implement the localization in French and Dutch, so I hope with the new version it will be again the jQuery style: smooth and easy.

jQuery UI also has a new widget: the long awaited Autocomplete. The only good solution I had for an autocomplete with jQuery was JAMES. I hop the new UI has an even better solution.

From the moment I can test all of this, I’ll write about my experiences!

Implementing a menu with Zend_Navigation

A few weeks ago I saw a very good ZendCast about Zend_Navigation.

This was a very good start for me to use Zend_Navigation for the menu and breadcrumbs in my application.


While developing there were some performance issues that came up:

  1. parsing a .ini or .xml file makes the application slower
  2. for Ajax-requests, the menu should not be loaded

The solution for the first problem is a simple array. I created a function getMenu() that returns a Zend_Navigation object, and this object contains my menu array. The array is less readable than a .ini or .xml file, I have to admit, but it’s still very easy to work with.

private function getMenu()
    return new Zend_Navigation(array(
            'label' => 'Home',
            'id' => 'home',
            'visible' => false,
            'controller' => 'index',
            'action' => 'index'
            'label' => 'Page 1',
            'id' => 'page_1',
            'uri' => '',
            'pages' => array(
                    'label' => 'Page 1.1',
                    'id' => 'page_1_1',
                    'controller' => 'general',
                    'action' => 'index'

For the second problem I had to dig a little bit deeper into Zend Framework.
Normally the Zend_Layout and Zend_View are created in the bootstrap. And this is also the place where I would initialize Zend_Navigation.
For an Ajax request, I disable the layout.


Does it make sense to first create the layout and view, then add the menu to the view, and afterwards disable the layout if the application do an Ajax request?

My solution was this: I created a plugin for the menu. This plugin checks if the layout is enabled or disabled, and only creates the menu when the layout is enabled. The plugin uses the postDispatch method, because only then the layout can be checked if it is enabled or disabled. In the preDispatch it is always enabled.

public function postDispatch(Zend_Controller_Request_Abstract $request)
    $layout = Zend_Layout::getMVCInstance();
    $view = $layout->getView();
    if ($layout->isEnabled() && Zend_Auth::getInstance()>hasIdentity()) {

Difference between URI and MVC

This is a very simple difference.

Zend_Navigation_Page_Mvc uses the parameters “controller” and “action” to create the anchors in the menu.
Zend_Navigation_Page_Uri uses the “uri” parameter the create the anchor.

I use only Mvc to create my anchors.
I use the Uri for one case: if I want a menu item that has no anchor. If the “uri” parameter is left blank, Zend_Navigation will display the label, but it will not create anchor tags around it, so you can create a nice menu with menu titles that are not linkable, and menu items with links underneath

MySQL Proxy

When I start programming, the first thing I do is… starting MySQL Proxy.

This is a very small program that runs between the web server and database server. It’s behaviour can be configured with a LUA script.

I will not give a complete overview of everything that the MySQL Proxy can do. If you want this, go to the homepage of the proxy.

How does it work?

You start the MySQL Proxy in command line, and give some parameters with it. The most important ones are:

  • the LUA script to run
  • the database server host and port
mysql-proxy.exe --proxy-lua-script=script.lua

In your local application code (PHP in my case), instead of configuring your database to the <db_server> and <port>, you write “localhost” for the host and “4040” for the port. Now the local web server connects to the MySQL Proxy, and the proxy sends the queries to the database server.

What does it do?

In my case, I use it to monitor all the queries that my web server sends to the database. When I start my application in the browser, I see the queries passing in the command line window. Here is an example:

-MySQL Query- SET NAMES 'utf8'
-REQtime- 0ms
-QueryNr- 1
-Conn.Nr- 1
     AS user_id,
     AS name,
              u.address AS address,
              p.postal_code AS postal_code,
     AS city
              FROM user u
              LEFT JOIN postal_code p
              ON (u.post_id = p.post_id)
              WHERE LIKE 'Joh%'
              ORDER BY name ASC
              LIMIT 0,25
-REQtime- 15.625ms
-QueryNr- 2
-Conn.Nr- 1


  • Is my query generated correctly? Where is the error in my query? The standard error messages from MySQL are most of the time not very clear, and don’t give enough information to find the bug in the query. With MySQL Proxy you see the generated query, and this makes it easier to discover the problem
  • How long does my query take?
  • Did the transaction commit or roll back?
  • Is the “set names” send to the database or not?
  • Why does my application generate 200 queries when I load it?

These are questions that can be answered more easily with the MySQL Proxy, and it makes debugging a lot easier!

The goal

Probably it already happened to you too: you encounter a problem while coding, and you think “I have had this problem before, but how did I solve it? …”

It tends to happen to me once in a while, and then I think, I should have written it down somewhere. Now I finally have the place to write this down. Not only can this be handy for myself, but also for other people who run into problems while making a cool PHP application.

Besides this, there is a lot of other stuff to talk about:

  • conferences,
  • other interesting posts I read and want to share,
  • reviews of new versions of all PHP-related software, for example Zend Framework, jQuery, MySQL