我已經成功地從數據庫中刪除節點(我檢查了它),但問題是nid不會在節點引用字段中消失。我如何刪除這個?這裏是我的代碼dosnt工作如何刪除drupal中的節點引用類型6
if($op == 'delete' && $node->type == 'person'){
$id = $node->nid;
$q=db_query("select nid from content_field_movie_cast where field_movie_cast_nid = '$id'"); //get all the movie ids that have the cast
db_query("DELETE from content_field_movie_cast where field_movie_cast_nid = '$id' "); // delete all the entry for that cast in a all the movies it is involve
while($result=db_fetch_array($q)){
$node1=node_load($result['nid']);
$ctr=0;
$cnt=count($node1->field_movie_cast);
while($ctr<$cnt){
if($node1->field_movie_cast[$ctr]['nid']==$id){
dpm($node1->field_movie_cast[$ctr]['nid']=0);
node_delete($nid);
}
$ctr++;
}
db_query("update content_type_movie set field_movie_cast_count_value =field_movie_cast_count_value -1 where nid = '".$result['nid']."' ");
}
}
這裏有一張過的什麼IM談論沒有名字的NID是一個我想刪除
從你上次的幾個問題來看,這聽起來像你正在尋找[CCK的參考完整性](http://drupal.org/project/cck_referential_integrity)...我的理解是,將取代你的習慣的需要代碼,它看起來是穩定的0開放的錯誤 – Clive 2013-03-19 16:23:00
如何使用它? – 2013-03-19 16:53:07
鄧諾我從來沒有使用它,但它是爲你的目的而建造的。安裝在您的開發網站上,看看... – Clive 2013-03-19 16:58:16