Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in SQL by (20.3k points)

In the footer of my page, I would like to add something like "last updated the xx/xx/200x" with this date being the last time a certain MySQL table has been updated.

What is the best way to do that? Is there a function to retrieve the last updated date? Should I access the database every time I need this value?

1 Answer

0 votes
by (40.7k points)

In MySQL's latest version you can use the information_schema database if another table is already updated like this:


FROM   information_schema.tables


   AND TABLE_NAME = 'tabname'

This will help you to open a connection to the database.

The other option is to "touch" a particular file whenever the MySQL table is updated, you'll find it on database updates:

Open your timestamp file in O_RDRW mode

close it again

0 or alternatively

To change the file timestamp, you can use touch() which is PHP equivalent of the utimes() function, and you will find it on On-page display:

use stat() to read back the file modification time.

Enroll yourself in the best sql courses to learn in-depth about SQL statements, queries and become proficient in SQL.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 11, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer

Browse Categories