You are here

function filefield_paths_install in File (Field) Paths 6

Same name and namespace in other branches
  1. 8 filefield_paths.install \filefield_paths_install()
  2. 5 filefield_paths.install \filefield_paths_install()
  3. 6.2 filefield_paths.install \filefield_paths_install()
  4. 7 filefield_paths.install \filefield_paths_install()

Implements hook_install().

File

./filefield_paths.install, line 45
Install, update and uninstall functions for the FileField Paths module.

Code

function filefield_paths_install() {
  drupal_install_schema('filefield_paths');
  db_add_field($ret = array(), 'files', 'origname', array(
    'description' => 'Original name of the file.',
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
  $result = db_query("SELECT fid, filename FROM {files}");
  while ($file = db_fetch_object($result)) {
    db_query("UPDATE {files} SET origname = '%s' WHERE fid = %d", $file->filename, $file->fid);
  }
  variable_set('filefield_paths_schema_version', 6103);
}