You are here

function themekey_update_6001 in ThemeKey 7

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

Implements hook_update_N().

Update property 'nid' to 'node:nid'

File

./themekey.install, line 111
Database schema of

Code

function themekey_update_6001() {
  $result = db_query('SELECT * FROM {themekey_properties} WHERE property = :property', array(
    ':property' => 'nid',
  ));
  foreach ($result as $item) {
    if (db_query('SELECT COUNT(id) FROM {themekey_properties} WHERE property = :property AND value = :value', array(
      ':property' => 'node:nid',
      ':value' => $item->value,
    ))
      ->fetchField() > 0) {
      db_delete('themekey_properties')
        ->condition('id', $item->id, '=')
        ->execute();
    }
    else {
      $num_updated = db_update('themekey_properties')
        ->fields(array(
        'property' => 'node:nid',
      ))
        ->condition('id', $item->id, '=')
        ->execute();
    }
  }
  return t('Updated property "nid" to "node:nid"');
}