Check Node is Exists In Drupal

It is good way to check Node is exists or not bellow example code would be helpful 

In this example , If node is exists in our database, then It will be deleted. otherwise give a error message and redirect to perticular page.

Example :
  $bolIsNodeAvail = node_load(array('nid' => $intNodeId)); 
  if($bolIsNodeAvail != false)
  {
        node_delete($intNodeId);  
  }else{
        drupal_set_message(t("node id is not exists."), 'error');  
  }
  drupal_goto('ess_upload/album_images');
 

No comments: