You are here

function imagefield_update_5 in ImageField 5.2

Set fid to 0 where files have been deleted.

File

./imagefield.install, line 109

Code

function imagefield_update_5() {
  $ret = array();
  $fields = content_fields();
  foreach ($fields as $field) {
    if ($field['type'] == 'image') {
      $db_info = content_database_info($field);
      if (isset($db_info['columns']['fid'])) {
        $table = $db_info['table'];
        $column = $db_info['columns']['fid']['column'];
        $ret[] = update_sql("UPDATE {" . $table . "} SET {$column} = 0 WHERE {$column} NOT IN (SELECT fid FROM {files})");
      }
    }
  }
  return $ret;
}