mysqlphpmyadminadmin

Can I use phpMyAdmin or MySQL to check when a record was made or modified without a timestamp column?


Scenario.

Simple database which has a list of addresses

addressID
FirstName
LastName
City
PostCode
CountyID
ZoneID

The problem is that by default this table doesn't have a creation or timestamp column at the end. However I have full access to MySQL through my Nginx SSH Ubuntu 11 setup - I can also login to root phpMyAdmin.

Can I check for example when a particular entry was made, modified etc ?


Solution

  • In short, no. This is not impossible 99% of the time. Especially in the environment being MySQL. NoSQL and other services like MongoDB and other environments differ.

    Run this script in phpMyAdmin for future use now (you already suggested you were going to make a stamp record).

    ALTER  TABLE Addresses
    ADD Column CreatedOrModified timestamp
    NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
    

    You can also use the NULL and also DateTime Stamp for the default values. You can also have PHP send the Data inside the MySQL field:

    $stamp=$date=date("Y-m-d H:i:s");