douyou2048 2013-09-10 16:50
浏览 55
已采纳

Drupal查询没有更新

<?php
$search = array('.pdf', '.', '-', '_');
$replace = array('', '/', '</u>- ', ' ');
$query="SELECT  STR_TO_DATE(SUBSTR(`filename`, 1, 10),'%m.%d.%Y') as filedate, `filename`, `filepath`
FROM  `files`  
WHERE `filepath` LIKE 'sites/default/files/news/%' 
ORDER BY filedate DESC
LIMIT 4";
$results = db_query($query);

while ($row = db_fetch_array($results)) {
    echo '<tr>';
    echo '<td><u><a href=http://website.com/sites/default/files/news/'. $row["filename"] . '>' . str_replace($search, $replace, $row["filename"]) . '</a></td><br />';
    echo '</tr>';
}
?>

I have this code on the homepage of my website. It pulls all files in a certain folder that start with a date. Currently, when I add a new file, the query doesn't update, even though when I run the query in PHPmyadmin it works fine.

What's happening to make the query not update itself? Flushing cache's haven't worked for me.

  • 写回答

1条回答 默认 最新

  • drq61040 2013-09-10 18:04
    关注

    First of all, your not trying to update, your pulling data from the database.

    I would suggest you use file_scan_directory.

    https://api.drupal.org/api/drupal/includes!file.inc/function/file_scan_directory/7

    <?php
    $files = file_scan_directory('/sites/default/files/news', '/.*\.pdf$/');
    foreach ($files as $file) {
      print $file->filename;
    }
    ?>
    

    Above code is not directly tested.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失