function dba_edit_row in Database Administration 5
1 string reference to 'dba_edit_row'
- dba_admin_tables_view in ./
dba.module - Display the contents of the selected table.
File
- ./
dba.module, line 559 - 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($table, $key, $keyid) {
$rows = array();
$keyid = str_replace('__2F_', '/', $keyid);
$result = db_query("SELECT * FROM %s WHERE %s = '%s'", $table, $key, $keyid);
$row = db_fetch_array($result);
$header = array_keys($row);
foreach ($row as $k => $value) {
if ($k == $key) {
$form['key'] = array(
'#type' => 'markup',
'#value' => $value,
);
}
else {
// We store all fields in sub-array 'fields' to avoid naming collisions.
$size = strlen($value);
if ($size > 255) {
$form['field'][$k] = array(
'#type' => 'textarea',
'#default_value' => $value,
'#cols' => 70,
'#rows' => 10,
);
}
else {
$form['field'][$k] = array(
'#type' => 'textfield',
'#default_value' => $value,
'#size' => $size,
'#maxlength' => 255,
);
}
}
}
$form['header'] = array(
'#type' => 'hidden',
'#value' => implode(',', $header),
);
$form['table'] = array(
'#type' => 'hidden',
'#value' => $table,
);
$form['key'] = array(
'#type' => 'hidden',
'#value' => $key,
);
$form['keyid'] = array(
'#type' => 'hidden',
'#value' => $keyid,
);
return confirm_form($form, t('Edit row from the "%table" table', array(
'%table' => $table,
)), "admin/build/database/table/{$table}/view", t('By clicking "Edit row" you will save any changes you make to this row of the %table table. This action cannot be undone.', array(
'%table' => $table,
)), t('Edit row'), t('Cancel'));
}