You are here

function dba_query_form in Database Administration 5

2 string references to 'dba_query_form'
dba_menu in ./dba.module
dba_query_form_pre_render in ./dba.module

File

./dba.module, line 765
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_query_form() {

  // Now, add a text area for the admin to enter a query.
  $form['query'] = array(
    '#type' => 'fieldset',
    '#title' => t('Query'),
  );
  $form['query']['dba_query'] = array(
    '#type' => 'textarea',
    '#title' => t('Database query'),
    '#cols' => 70,
    '#rows' => 10,
    '#description' => t('Enter the text of your database query.  This will be executed directly in your database, so the action can not be undone.  Do not wrap your tables in {}, as direct database queries do not support Drupal\'s database prefixing.  If you are using a database prefix, you will need to manually include the prefix in your table name.  Separate multiple queries with a ";".  A sample query: \'SELECT COUNT(*) FROM accesslog;\''),
  );
  $form['query']['actions'] = array(
    '#prefix' => '<div class="container-inline">',
    '#suffix' => '</div>',
  );
  $form['query']['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Execute query'),
  );
  $form['query']['actions']['cancel'] = array(
    '#type' => 'markup',
    '#value' => l(t('Cancel'), 'admin/database'),
  );

  // We use #pre_render, so that we can safely use validated form values
  // to see if a query has been entered, and if so, run the query and
  // dynamically generate other form elements to display the results.
  $form['#pre_render'][] = 'dba_query_form_pre_render';

  // We don't want to get redirected, which would run the queries twice.
  $form['#redirect'] = false;
  return $form;
}