Select data from database when submitting a form I'm trying to learn how to make select queries with Drupal, so I made a form, and when I submit the form I try to query the database and get some results, but instead I'm redirected to an error page, here's how I select nodes from DB :

function my_module_form_submit($form, &amp;$form_state)
{
    $query = db_select('node', 'n')-&gt;extend('PagerDefault');
    $query-&gt;condition('type', 'myContentType');
    $result = $query-&gt;execute();
}
You have missed fields() &amp; fetch type -- fetchAll().

Below is the working example. You can find more details here (db_select API) 

$query = db_select('node', 'n')-&gt;extend('PagerDefault');
$query-&gt;fields('n'); // This is like select *. You can retrieve specific fields too.
$query-&gt;condition('type', 'article');
$result = $query-&gt;execute()-&gt;fetchAll(); // you can fetch by object, array, etc...
print_r($result);