
CodeIgniter, WordPress, jQuery, PHP & JavaScript Programmer
Written on December 14, 2009 by Zaki and 2 peoples have comment

Written on December 07, 2009 by Zaki and 2 peoples have comment

Conventionally getting today date from database in the past would require the use of date('Y-m-d'); function and add it to MySQL query such as below:
$today_date = date('Y-m-d');
$tmrw_date = date('Y-m-d', strtotime("+1 day"));
$sql = "SELECT * FROM my_table
WHERE my_datetime BETWEEN '" . $today_date . "' AND '" . $tmrw_date . "'";
However this method might return false positive result if the web server and database server doesn’t have it date and time synchronized. From my point of view, it best to let the database server have the full control to insert, update or compare the dates. So what the alternative? You can check the full specification from MySQL Date and Time Functions but I would opt for DATEDIFF if you specifically want to compare with today date.
SELECT * FROM my_table
WHERE DATEDIFF(my_datetime, SYSDATE())=0
Written on November 04, 2009 by Zaki and No one have comment
Yes, I have a problem with CodeIgniter built-in Form Validation Library, the lack of direct Regular Expression test/rule is a huge turn off for me especially when I need to use Regular Expression to as a rule to verify user input.
There are alternative with the use of “callback” to by creating an additional method inside your Controller. The solution is good if you have a complex filtering but why bother when all you need to do is a simple RegExp verification. Based on my Twitter status:
Written on November 03, 2009 by Zaki and 8 peoples have comment
Recent Comments