You are here

function dba_edit_row_submit in Database Administration 5

File

./dba.module, line 624
Allows administrators direct access to their Drupal database. Written by Jeremy Andrews <jeremy@kerneltrap.org>, June 2004. PostgreSQL functionality provided by AAM <aam@ugpl.de> Major security audit, porting, and maintenance by Derek…

Code

function dba_edit_row_submit($form_id, $form_values) {
  if (user_access('dba administer database')) {
    $key = $form_values['key'];
    $keyid = $form_values['keyid'];
    $table = $form_values['table'];
    $fields = dba_get_fields($table);
    foreach ($fields as $field) {
      if ($field != $key) {
        $value = "{$form_values[$field]}";
        if (isset($query)) {
          $query .= ", {$field} = '" . db_escape_string($value) . "'";
        }
        else {
          $query = "{$field} = '" . db_escape_string($value) . "'";
        }
      }
    }

    // @todo Manual prefixing
    $query = "UPDATE {$table} SET {$query} WHERE {$key} = '{$keyid}'";
    drupal_set_message(check_plain($query));

    // Use _db_query so we preserve {}'s.
    _db_query($query);
  }
  return "admin/build/database/table/{$table}/view";
}