Monthly Archives: April 2009

Have you ever been in a situation that you need to install PHP5 to have one application which is spcifically written in PHP5 and you have also some legacy applications which are written in PHP4 and are not compatible with PHP5 but you want to have them both.

I used to hate all those software bundles installing Apache/MySQL/PHP for you easily. I prefered to have them separately installed by myself to have more control over it. But considering WAMP server with an amazing feature of having many versions of Apache/MySQL/PHP and just switch from one to another by right-clicking and selecting it, is awesome.

I’ll definitely consider it for my local machine. [First need to be done with my exam on Wednesday]

We have a traffic table which monitors every single coming traffic to our applciation. I wanted to get the real values for how many requests I we have per Second / Minute / Hour and also what times of the the day are high traffic and what times are low traffic, to do some load-balancing on the application and server.

The query is very simple, just COUNT the number and do a GROUP BY and extract the minute/hour/…

Like :

SELECT tr_date_time,count(*) AS NUM FROM `traffic`
WHERE DATE(`tr_date_time`) = '2009-04-25'
GROUP BY EXTRACT(HOUR_MINUTE FROM tr_date_time);

The script above extracts the number of hits per minute during the day.
Don’t forget that if you want to have the result by minutes, you have to add the hour as well to make it unique.

p.s: I hope your Date/Time/DateTime field is human friendly not Unix_timestamp, which will add some more extra calcuations on the result set.

When you use that perfect xss_clean function from CodeIgniter’s library to make your content more robust, sometimes you may face a strange content being updated in DB having “;” after “&” or before “=” .

That “;” is added by xss_clean, to make the link more robust, but if in your case it will add some malfunctioning in your system you’d better use something else in your validations like “htmlentities” :

$rules['link'] = "required|trim|htmlentities";

For more information regarding that you can refer to CI forums. [thread1] [thread2]