Wednesday, July 22, 2009

INSERT ON DUPLICATE KEY UPDATE and REPLACE INTO

While reading and article came across one of powerful feature REPLACE INTO,I had used INSERT ON DUPLICATE KEY UPDATE but never used REPLACE INTO.

REPLACE works in a way that if the ID column(Primary Column) doesn't have the given value it will create a new entry in the table, however, IF the value exists already then it updates the existing entry in the table.

REPLACE INTO sessions VALUES ('$id', '$data', $ts).

Read about REPLACE INTO and Difference about INSERT ON DUPLICATE KEY UPDATE vs REPLACE INTO

Sunday, July 19, 2009

PHP: exceptions vs errors?

Was just reading twitts got the nice link about the exceptions handling the post basically explains about handling errors in PHP nice one check out the code how the fatal error are handled and customize message is displayed for user. I have not tested the code but looks ok :) . Click for post here

Wednesday, July 15, 2009

Debug message in PHP?

I am using PHP from past 4 year and used to debug my code using die and echo statement and will log the debug message in file if running backend job(Cron) while using PHP 4 and then we started using Zend Framework and use Zend_log. But for those who won't use Zend Framework here is the function which will be useful in debug debug_backtrace this function is available from PHP4 didn't know i just came to know while i was browsing php.net, This information is for user like me who didn't know about it :)

Monday, July 06, 2009

Install PHP 5.3 on WAMP Server

Just installed PHP 5.3.0 on WAMP, Nice addon facility in WAMP now can switch between 5.2.x and 5.3.0. It was so simple that even a person with little knowledge can do it.

First install WAMP.
Then download version of php you want and install from here.
Done.

Now go to the wamp server icon in tray and switch to the version you want :)

PHP Security

Good article written by Joel Reyes about PHP Security, Author has explained some of the security holes we have to take care also given link for security tool download. Go through the article worth reading.