未定义的函数db_fetch_array()

时间:2017-03-09 04:49:03

标签: drupal-7 drupal-6 drupal-modules drupal-8

当我尝试将drupal 6模块转换为drupal 7时,我收到此错误。我已经了解到drupal 7在数据库中有一个新api。我希望有人能给出解决此问题的方法。< / p>

 db_set_active('data');
    $ncoa=db_fetch_array(db_query("SELECT deskripsi FROM {coa} WHERE coaid = '$baris->coa'"));
    $ukpengelola=db_fetch_array(db_query("SELECT lokasi FROM {costcenter} WHERE kodecost = '$baris->kodecost'"));
    $ukpengguna=db_fetch_array(db_query("SELECT lokasi FROM {costcenter} WHERE kodecost = '$baris->kodecostpemakai'"));
    $zstatus=db_fetch_array(db_query("SELECT status_deskripsi AS zket FROM {pengadaan_zstatus} WHERE status_id = '$baris->status_id'"));
    db_set_active('default');

1 个答案:

答案 0 :(得分:0)

db_fetch_array()在D7中折旧,有关如何修复的参考,请参阅http://drupal.org/update/modules/6/7#dbtng

示例 - Drupal 6:

<?php
$result = db_fetch_array(db_query("SELECT * FROM {boxes} WHERE bid = %d", $bid));
?>

Drupal 7:

<?php
$result = db_query("SELECT * FROM {block_custom} WHERE bid = :bid", array(':bid' => $bid))->fetchAssoc();
?>