How to retrieve data from custom table in database? I created a custom table in my modules .install file and I am asking for some form input in a custom made configuration file. I am unable to retrieve that data and print it out in a custom callback page that i created for testing. I'm not quite sure what i am doing wrong.

&lt;?php
/* mymodule.install */
function mymodule_schema(){
  $schema['mymodule'] = array(
    'description' =&gt; 'Table for testing',
    'fields' =&gt; array(
      'pmid' =&gt; array(
        'type' =&gt; 'int',
        'unsigned' =&gt; TRUE,
        'not null' =&gt; TRUE,
        'default' =&gt; 0,
      ),
      'field_one' =&gt; array(
        'description' =&gt; 'Field 1',
        'type' =&gt; 'varchar',
        'length' =&gt; 255,
        'not null' =&gt; TRUE,
        'default' =&gt; ''
      ),
      'primary key' =&gt; array('pmid'),
      'unique keys' =&gt; array(
        'pmid' =&gt; array('pmid'),
      ),
     ),
   );

/* mymodule.module */
function mymodule_form_submit($form, &amp;$form_state){
  db_insert('mymodule')
  -&gt;fields(array(
    'field_one' =&gt; $form_state['values']['field_one'],
    'pmid' =&gt; 1,
  ))-&gt;execute();
}

function mymodule_print_table(){
$result = db_select('mymodule', 'mm')
       -&gt;fields('field_one') 
       -&gt;execute()
       -&gt;fetchAll();
var_dump($result);
}


This prints an empty array for me.

EDIT:

I incorrectly assumed form_submit was a hook and didn't add it to my form.

function mymodule_form($form, &amp;$form_state){
$form['field_one'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('Field One'),
    '#default_value' =&gt; '',
    '#description' =&gt; t('Field One Test'),
    '#required' =&gt; true,
  );
//This was missing
$form['#submit'][] = 'mymodule_form_submit';

return system_settings_form($form);
}
The fields method takes a table name/alias as its first arg, and an array of field names as its second:

$result = db_select('mymodule', 'mm')
   -&gt;fields('mm', ['field_one']) 
   -&gt;execute()
   -&gt;fetchAll();