0

I've been working to upgrade D6 to D7 but when I run my custom module then received error. what should I do to fix this error or change the db_error API that drupal 7 know as db_error

Here my code

if  ($_SESSION['opr'] == 'add') {  
  db_set_active('data');
  db_query("INSERT INTO neraca (tahun,triwulan,item_neraca,nilai,is_final,createdby,createdon,updateby,updateon ) 
            VALUES('$tahun','$triwulan','$itemneraca',$nilai, $isfinal, $inputby,'$inputdate',$updateby,'$updatedate' )");

  $error = db_error();
  if ($error != NULL) {
    db_set_active('default');  
    drupal_set_message($message='Data belum tersimpan, ada kesalahan !!!', $type='error');
    drupal_goto('in_settingdatalaporan');
    return;
  }
}
else {
  db_set_active('data');
  db_query("UPDATE neraca set tahun='$tahun',triwulan='$triwulan',item_neraca='$itemneraca',nilai=$nilai,is_final=$isfinal,updateby=$updateby,updateon='$updatedate' where id=$id ");

  $error = db_error();
  if ($error != NULL) {
    db_set_active('default');  
    drupal_set_message($message='Data belum tersimpan, ada kesalahan !!!', $type='error');
    drupal_goto('in_settingdatalaporan');
    return;
  }
}
db_set_active('default');   
drupal_set_message('Submit Data berhasil');
drupal_goto('in_settingdatalaporan');
return;
}
Cyclonecode
  • 29,115
  • 11
  • 72
  • 93
ipin upin
  • 21
  • 1
  • 10
  • What have you tried already? Seems like you will need to change alot in that code to use the Drupal 7 database API. Here is a question relating to `db_error()` which was removed from Drupal 7. http://drupal.stackexchange.com/questions/91281/drupal-7-db-error-equivalent – 2pha Mar 17 '17 at 09:28
  • Use backup and migrate module to do this ! https://www.drupal.org/project/backup_migrate – Fky Mar 17 '17 at 16:00

0 Answers0