Click here to Skip to main content
15,867,860 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Trying to get the time when the table was last updated.

The code below returns either "-1" or shows 'Commands out of sync' Error

Also, I am not sure what's the best way to get the last updated time for each row of a table.

**Table gets dropped when a new file is uploaded and a new table if created. Thus Create_Time.

What I have tried:

SQL
$timeupdated = $db->multi_query('SELECT UPDATE_TIME FROM INFORMATION_SCHEMA.TABLES WHERE `TABLE_SCHEMA` = "dbname" AND `TABLE_NAME` = "tablename"');

if ($timeupdated == -1) echo "No Update Time Found"; //returns -1 without this

else{
$timecreated = $db->multi_query('SELECT CREATE_TIME FROM INFORMATION_SCHEMA.TABLES WHERE `TABLE_SCHEMA` = "dbname" AND `TABLE_NAME` = "tablename"');
echo $timecreated;}
echo $timeupdated;
Posted
Comments
Peter_in_2780 26-Feb-17 23:38pm    
If you want the update time for each row, the easiest way is to add a timestamp column. Set it to "now" whenever you do an add or update.
Member 13027553 27-Feb-17 22:21pm    
What does "-1" mean?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900