Jump to content

ORDER BY file modification time


skwap

Recommended Posts

I have a table in my database which stores lot of file names & file path. iam currently listing the files on the basis of its uploaded date (stored in databse) but  I want to list it on the basis of its file modification time.

How i can do it ??

my current sql statement is

 

$sql = mysql_query("SELECT * FROM `files` WHERE `cid` = '$types' ORDER BY `uploaded` DESC LIMIT $start,$limit");

 

anyone can help me ??

Link to comment
https://forums.phpfreaks.com/topic/245868-order-by-file-modification-time/
Share on other sites

Unless you create an automated process to interrogate the files and update the database with the file modified timestamp, you can't do this through a MySQL query. You will need to query the files, then when processing them add them to an array and at the same time get the modification time and add to the array as well. then you can order the array and finally output the data.

 

However, if this is for a pagination script, this will not help you since you need to have the order of the files so you can get the correct files for the page using LIMIT. In that case you can either create an automated process to continually read the files and update the database OR you will have to query ALL the records, determine their modification dates, order them - in PHP - then use PHP code to determine which ones are for the current page. Neither option is a very good one.

can you tell me which function can i use to get proper file modification time ?

 

A simple google search for something like "php file modification" would tell you that. I love helping people, but when someone asks me to do something that they can easily do themselves I get peeved. :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.