You are here

function pathauto_persist_entity_state_save in Pathauto Persistent State 6

Same name and namespace in other branches
  1. 7 pathauto_persist.module \pathauto_persist_entity_state_save()
1 call to pathauto_persist_entity_state_save()
pathauto_persist_nodeapi in ./pathauto_persist.module
Implements hook_nodeapi().

File

./pathauto_persist.module, line 20

Code

function pathauto_persist_entity_state_save($entity_type, $entity_id, $pathauto_state) {
  $current_state = db_result(db_query("SELECT pathauto FROM {pathauto_persist} WHERE entity_type = '%s' AND entity_id = %d", $entity_type, $entity_id));
  if ($current_state === FALSE) {
    db_query("INSERT INTO {pathauto_persist} (entity_type, entity_id, pathauto) VALUES ('%s', %d, %d)", $entity_type, $entity_id, $pathauto_state);
  }
  elseif ($current_state != $pathauto_state) {
    db_query("UPDATE {pathauto_persist} SET pathauto = %d  WHERE entity_type = '%s' AND entity_id = %d", $pathauto_state, $entity_type, $entity_id);
  }
}