You are here

function themekey_update_6001 in ThemeKey 6

Same name and namespace in other branches
  1. 6.4 themekey.install \themekey_update_6001()
  2. 6.2 themekey.install \themekey_update_6001()
  3. 6.3 themekey.install \themekey_update_6001()
  4. 7.3 themekey.install \themekey_update_6001()
  5. 7 themekey.install \themekey_update_6001()
  6. 7.2 themekey.install \themekey_update_6001()

Implementation of hook_update_N(). (Update property 'nid' to 'node:nid')

File

./themekey.install, line 71

Code

function themekey_update_6001() {
  $ret = array();

  //
  $result = db_query('SELECT * FROM {themekey_properties} WHERE property = \'nid\'');
  while ($item = db_fetch_array($result)) {
    if (db_result(db_query('SELECT COUNT(id) FROM {themekey_properties} WHERE property = \'node:nid\' AND value = \'%s\'', $item['value'])) > 0) {
      $ret[] = update_sql('DELETE FROM {themekey_properties} WHERE id = ' . $item['id']);
    }
    else {
      $ret[] = update_sql('UPDATE {themekey_properties} SET property = \'node:nid\' WHERE id = ' . $item['id']);
    }
  }
  return $ret;
}