You are here

function _uc_file_prune_db in Ubercart 8.4

Same name and namespace in other branches
  1. 6.2 uc_file/uc_file.module \_uc_file_prune_db()
  2. 7.3 uc_file/uc_file.module \_uc_file_prune_db()

Removes all db entries associated with a given $fid.

3 calls to _uc_file_prune_db()
uc_file_empty in uc_file/uc_file.module
Removes all downloadable files, as well as their associations.
uc_file_remove_by_id in uc_file/uc_file.module
Deletes files (or directories).
_uc_file_prune_files in uc_file/uc_file.module
Removes non-existent files.

File

uc_file/uc_file.module, line 382
Allows products to be associated with downloadable files.

Code

function _uc_file_prune_db($fid) {
  $connection = \Drupal::database();
  $pfids = $connection
    ->query('SELECT pfid FROM {uc_file_products} WHERE fid = :fid', [
    ':fid' => $fid,
  ]);
  $connection = \Drupal::database();
  while ($pfid = $pfids
    ->fetchField()) {
    $connection
      ->delete('uc_product_features')
      ->condition('pfid', $pfid)
      ->condition('fid', 'file')
      ->execute();
    $connection
      ->delete('uc_file_products')
      ->condition('pfid', $pfid)
      ->execute();
  }
  $connection
    ->delete('uc_file_users')
    ->condition('fid', $fid)
    ->execute();
  $connection
    ->delete('uc_files')
    ->condition('fid', $fid)
    ->execute();
}