我试图在1天之内获得最多下载的项目,所以我做了一个下载表,它的结构是:
upload_id-> 26
下载日期-> 2019-01-10 23:19:13
,并使用该代码在1天内完成了大多数下载的ID
Document.CreateElement("A")
我得到像这样的$ ids
$stmt = $db->prepare( "SELECT download_id,COUNT(upload_id),download_date,upload_id FROM downloads WHERE DATE(download_date) > DATE(CAST(now() - INTERVAL 1 DAY AS DATE)) GROUP BY upload_id ORDER BY count(upload_id) DESC LIMIT 4" );
$stmt->execute();
$fetchData = $stmt->fetchAll();
$ids = '';
foreach ($fetchData as $data) {
if( $ids =='' ):
$ids = $data['upload_id'];
else:
$ids .= ','.$data['upload_id'];
endif;
然后我使用了另一个代码从具有这些ID的项目表中获取行
$ids= 21,6,25,21;
问题是我得到项目表中ID顺序的记录而不是$ ids顺序,那么我没有得到正确的结果,如何获得$ ids顺序的记录?