You are here

function kwresearch_delete_page_keywords_by_page in Keyword Research 7

Same name and namespace in other branches
  1. 6 kwresearch.module \kwresearch_delete_page_keywords_by_page()

Deletes all the page keyword for a given page

Parameters

int|str $pid - If int, treated as a nid. If string treated as a path:

1 call to kwresearch_delete_page_keywords_by_page()
kwresearch_node_delete in ./kwresearch.module
Implements hook_node_delete().

File

./kwresearch.module, line 661

Code

function kwresearch_delete_page_keywords_by_page($pid) {
  $msgs = array();

  //TODO move $msgs to drupal_get_message;
  $page_keywords = kwresearch_load_page_keywords_by_page($pid);
  $pn = kwresearch_construct_pathnid_obj($pid, $msgs);
  $sql = "\n    DELETE FROM {kwresearch_page_keyword}\n    WHERE path = :path\n  ";
  $args = array(
    ':path' => $pn->path,
  );
  db_query($sql, $args);
  foreach ($page_keywords as $page_keyword) {
    kwresearch_update_keyword_page_counts($page_keyword->kid);
  }
}