Wednesday, December 10, 2014

MySQL date created and date modified




In MySQL table, we often have date created, date modified, creator and modifier.
We can set  both date created and date modified type as TIMESTAMP.
For date created, we can set the default CURRENT_TIMESTAMP.  As a result, when you insert a row into the table, the current date and time are automatically inserted into the column.

For Date modified , we can (in PHP)
 SET  DateModified = NOW(),

For Creator and modifier, we can use SESSIOn from PHP such as
  Creator      = {$this->sanitizeInput($_SESSION['sms_userName'])}, 

No comments:

Post a Comment