soycharliente Posted April 11, 2007 Share Posted April 11, 2007 In phpMyAdmin, each table knows the last time it was updated. Is that information available to me via some function? Couldn't find that it was anywhere through Google or asking a few fellow PHP programmers. Anyone know? Quote Link to comment https://forums.phpfreaks.com/topic/46598-solved-accessing-database-tables-last-update-information/ Share on other sites More sharing options...
boo_lolly Posted April 11, 2007 Share Posted April 11, 2007 are you looking for the 'time' in which the last row was updated, or simply to find the last row that was updated? Quote Link to comment https://forums.phpfreaks.com/topic/46598-solved-accessing-database-tables-last-update-information/#findComment-226826 Share on other sites More sharing options...
soycharliente Posted April 11, 2007 Author Share Posted April 11, 2007 The time. I see this when I choose a table to view. Row Statistics Statements Value Format dynamic Rows 2 Row length ø 154 Row size ø 2,202 Bytes Next Autoindex 3 Creation Feb 28, 2007 at 09:23 AM Last update Apr 10, 2007 at 04:40 PM I want that "Last update" info. Quote Link to comment https://forums.phpfreaks.com/topic/46598-solved-accessing-database-tables-last-update-information/#findComment-226831 Share on other sites More sharing options...
soycharliente Posted April 11, 2007 Author Share Posted April 11, 2007 Moving on up... Quote Link to comment https://forums.phpfreaks.com/topic/46598-solved-accessing-database-tables-last-update-information/#findComment-226866 Share on other sites More sharing options...
per1os Posted April 11, 2007 Share Posted April 11, 2007 Simple SQL SELECT * FROM tablename ORDER BY Lastupdate DESC LIMIT 1 Quote Link to comment https://forums.phpfreaks.com/topic/46598-solved-accessing-database-tables-last-update-information/#findComment-226905 Share on other sites More sharing options...
boo_lolly Posted April 11, 2007 Share Posted April 11, 2007 Simple SQL SELECT * FROM tablename ORDER BY Lastupdate DESC LIMIT 1 he doesn't have a column in his table that updates the time whenever anything else is updated. that would be the obvious addition to his code, but i was researching another way, if there was one. phpMyAdmin seems to do this automatically. Quote Link to comment https://forums.phpfreaks.com/topic/46598-solved-accessing-database-tables-last-update-information/#findComment-226918 Share on other sites More sharing options...
per1os Posted April 11, 2007 Share Posted April 11, 2007 Yea, I see that now. The most logical thing to do is add the update column and do that on your own instead of relying on MySQL to handle that for you. Quote Link to comment https://forums.phpfreaks.com/topic/46598-solved-accessing-database-tables-last-update-information/#findComment-226939 Share on other sites More sharing options...
boo_lolly Posted April 11, 2007 Share Posted April 11, 2007 Yea, I see that now. The most logical thing to do is add the update column and do that on your own instead of relying on MySQL to handle that for you. agreed. Quote Link to comment https://forums.phpfreaks.com/topic/46598-solved-accessing-database-tables-last-update-information/#findComment-226943 Share on other sites More sharing options...
soycharliente Posted April 11, 2007 Author Share Posted April 11, 2007 So are we saying that there is no function available to get that information and that I should just add another field to update what time the row was added/changed? I want the information to be able to see when the last update to certain tables was (i.e. some information changed on the site). Just seems like that's a lot to do for something so simple. Adding another field, making sure you set it every time it gets update, setting it initially when creating it, and returning it by ORDER BY foo LIMIT 1. Wish there was a returnLastUpdate($db, $table) function. Quote Link to comment https://forums.phpfreaks.com/topic/46598-solved-accessing-database-tables-last-update-information/#findComment-226960 Share on other sites More sharing options...
boo_lolly Posted April 11, 2007 Share Posted April 11, 2007 Wish there was a returnLastUpdate($db, $table) function. you can always write one... Quote Link to comment https://forums.phpfreaks.com/topic/46598-solved-accessing-database-tables-last-update-information/#findComment-226962 Share on other sites More sharing options...
soycharliente Posted April 11, 2007 Author Share Posted April 11, 2007 I'm talking about the info on the phpMyAdmin page available for the database. It displays stats about the table when you click on it. Quote Link to comment https://forums.phpfreaks.com/topic/46598-solved-accessing-database-tables-last-update-information/#findComment-226971 Share on other sites More sharing options...
sasa Posted April 11, 2007 Share Posted April 11, 2007 try $sql="SHOW TABLE STATUS LIKE 'table_name'"; Quote Link to comment https://forums.phpfreaks.com/topic/46598-solved-accessing-database-tables-last-update-information/#findComment-226976 Share on other sites More sharing options...
per1os Posted April 11, 2007 Share Posted April 11, 2007 $sql = "show table status"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) { print "Last update time for table " . $row['Name'] . " was " . $row['Update_time'] . "<br />"; } Perhaps that helps? Quote Link to comment https://forums.phpfreaks.com/topic/46598-solved-accessing-database-tables-last-update-information/#findComment-226977 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.