Permalink
Browse files

Fixed: custom field not saved when updating existing records

  • Loading branch information...
1 parent b80636b commit 226ba671a966fd43d267ba1cb100a321be0b27f1 Arie Nugraha committed May 29, 2010
Showing with 11 additions and 4 deletions.
  1. +11 −4 admin/modules/bibliography/index.php
@@ -166,12 +166,19 @@
$updateRecordID = (integer)$_POST['updateRecordID'];
// update data
$update = $sql_op->update('biblio', $data, 'biblio_id='.$updateRecordID);
- // update custom data
- if (isset($custom_data)) {
- $update2 = @$sql_op->update('biblio_custom', $custom_data, 'biblio_id='.$updateRecordID);
- }
// send an alert
if ($update) {
+ // update custom data
+ if (isset($custom_data)) {
+ // check if custom data for this record exists
+ $check_custom_q = $dbs->query('SELECT biblio_id FROM biblio_custom WHERE biblio_id='.$updateRecordID);
+ if ($check_custom_q->num_rows) {
+ $update2 = @$sql_op->update('biblio_custom', $custom_data, 'biblio_id='.$updateRecordID);
+ } else {
+ $custom_data['biblio_id'] = $updateRecordID;
+ @$sql_op->insert('biblio_custom', $custom_data);
+ }
+ }
if ($sysconf['bibliography_update_notification']) {
utility::jsAlert(__('Bibliography Data Successfully Updated'));
}

0 comments on commit 226ba67

Please sign in to comment.