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.