0

From what I'm gathering 'information_schema.tables' seems the way to go...

I'm wondering if I can approach this method from the php side; instead of going into mySQL workbench/client.

I'm trying the below; but getting an empty array. Is this possible? I will later simply display a 'Last Updated DD MM YYYY' in a .html page. It seems like this should be possible from my .php file?

It is a dynamic mySQL DB from a windows IIS server.. I have not made any modifications on the mySQL side at this point; only the below attempt. Seems like it should be a easy common task.

 <?php 
    $sql ="SELECT UPDATE_TIME FROM information_schema.tables WHERE 
    TABLE_SCHEMA = 'DB Name' AND TABLE_NAME = 'Table Name"; 
    $tableStatus = mysql_query($sql); 
     while ( 
    $row = mysql_fetch_assoc($tableStatus)) { $fetch[]= $row; echo $fetch;
 } ?>
Dr Upvote
  • 8,023
  • 24
  • 91
  • 204
  • 3
    When you execute this same query directly in MySQL, does it show the data you expect? – David Feb 18 '19 at 00:52
  • 1
    use `SELECT MAX(UPDATE_TIME ) as MAX_UPDATE_TIME from ...` for the most recent date from that table. PS `information_schema` is part of MySQL's structure. `it is a dynamic mySQL DB from a windows IIS server` its not dependent on server. Dont tell anyone I use it all the time to dynamically get the column names for tables, for security reasons ... :-) ie. key sanitization. – ArtisticPhoenix Feb 18 '19 at 00:58
  • Are you using literally `'DB NAME'` and `'Table Name'` in your query? I doubt your database and table have those names. Those are just examples. You should substitute with *your* actual database and table names. – Bill Karwin Feb 18 '19 at 01:04
  • Also, if you connect as a MySQL user who does not have privilege to read that database or table, the INFORMATION_SCHEMA will appear to be missing those entries. You will still be able to query for them, but the rows will not be visible to your user. – Bill Karwin Feb 18 '19 at 01:05
  • Possible duplicate of https://stackoverflow.com/questions/307438/how-can-i-tell-when-a-mysql-table-was-last-updated – Bill Karwin Feb 18 '19 at 01:12

0 Answers0