如何在drupal 6中删除节点引用类型

如何在drupal 6中删除节点引用类型,drupal,Drupal,我已经成功地从数据库中删除了节点(我检查了它),但问题是节点引用字段中的nid不会消失。如何删除此项?这是我不起作用的代码 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'"); //g

我已经成功地从数据库中删除了节点(我检查了它),但问题是节点引用字段中的nid不会消失。如何删除此项?这是我不起作用的代码

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']."' ");


    }
    }
if($op=='delete'&&&$node->type=='person'){
$id=$node->nid;
$q=db\u query(“从content\u field\u movie\u cast中选择nid,其中field\u movie\u cast\u nid='$id');//获取具有该演员阵容的所有电影id
db_query(“从内容中删除\u字段\u电影\u演员,其中字段\u电影\u演员\u nid='$id'”;//删除所有涉及的电影中该演员的所有条目
而($result=db\u fetch\u数组($q)){
$node1=节点加载($result['nid']);
$ctr=0;
$cnt=count($node1->field\u movie\u cast);
while($ctrfield\u movie\u cast[$ctr]['nid']==$id){
dpm($node1->field\u movie\u cast[$ctr]['nid']=0);
节点删除($nid);
}
$ctr++;
}
db_查询(“更新内容_类型_电影集字段_电影_演员_计数_值=字段_电影_演员_计数_值-1,其中nid=””。$result['nid']。“”);
}
}
这里有一张图片也是我所说的没有名字的nid是我想删除的


我已经有一段时间没有使用node\u ref.和D6了,尽管我对您的方法有点困惑。您从数据库中删除了节点吗?这意味着您从UI中删除了节点,或者是使用,而不是直接在数据库中执行奇怪的操作


引用此节点的节点仍将存储A->B引用。如果您编辑节点,它是否允许您保存它,通常它将重新请求。您需要在保存/预览之前删除不存在的引用ID。

虽然我认为这种方法有点奇怪,但我将采用以下编程方法:

function hook_form_alter(&$form, &$form_state, $form_id){
    //dsm($form);
    unset($form['field_movie_cast']['und'][0]['nid']['#default_value']);
}

这是基于D7的,因此对于D6,可能需要对代码进行轻微调整。

从您最近的两个问题来看,这听起来像是您在寻找的……我的理解是,这将取代您对自定义代码的需求,而且它看起来稳定,没有打开的bugsDunno我从未使用过它,但它正是为您的目的而构建的。在您的开发站点上安装它,并查看。。。