I can't believe I spent three hours trying to find out why the pager links were not showing up at the bottom of the table! In Drupal 4.7, I did not have to have SQL keywords (such as SELECT, FROM) in uppercase. Apparently, now I have to do it in Drupal 5.0. It would be nice, at least, to get an error message somewhere that says I had made an 'error' in my sql statement. The code below will fail with lowercase select,from but will work if changed to SELECT,FROM.


<?php

  $header = array(
    array('data' => t('id'), 'field' => 'id'),
    array('data' => t('type'), 'field' => 'type'),
    array('data' => t('label'), 'field' => 'label'),
  );

  $lines_per_page = 20;


  db_set_active('vpa');
  $sql= "select * from is_trigger";


  $sql .= tablesort_sql($header);
  $result = pager_query($sql, $lines_per_page);
  db_set_active();


  while ($obj = db_fetch_object($result)) {
    $rows[] = array(
        htmlspecialchars($obj->id),
        htmlspecialchars($obj->type),
        htmlspecialchars($obj->label),
    );
  }

  print theme('table', $header, $rows);
  print theme('pager','',$lines_per_page);


?>

Comments

curtgadget’s picture

I can confirm this bug as well.
I wasted about 3 hours myself tonight trying to figure this one out.
Im surprised it hasnt stumped more people.

KrisBuytaert’s picture

Suggested fix is documented in http://drupal.org/node/92381

dvessel’s picture

Title: theme('pager',..) picky about SQL statement » pager.inc picky about SQL statement
Component: theme system » base system

Not a theme issue.

dpearcefl’s picture

Status: Active » Closed (won't fix)

Considering the time elapsed between now and the last comment plus the fact that D5 is no longer supported, I am closing this ticket.