X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fdb_pager.inc;h=819b4757f5c7e3381b749f9bc3d7073b8ea187ec;hb=6cd42b4b7e4e5a199949a33fcf7fbd1f5d0ad3cb;hp=c34a855fa9234596320b603264d7057397f708f3;hpb=9f160ae3a3bf6d50bcceac382cf9cf685e793b65;p=fa-stable.git diff --git a/includes/db_pager.inc b/includes/db_pager.inc index c34a855f..819b4757 100644 --- a/includes/db_pager.inc +++ b/includes/db_pager.inc @@ -1,4 +1,14 @@ . +***********************************************************************/ // // Controler part of database table pager with column sort. // To display actual html object call display_db_pager($name) inside @@ -253,10 +263,10 @@ class db_pager { } $sql = "$select FROM $from $where"; - if($group) $sql.= " GROUP BY $group"; + if ($group) $sql.= " GROUP BY $group"; $ord = array(); - foreach( $this->columns as $col) { + foreach ($this->columns as $col) { if (isset($col['ord'])) { if ( $col['ord'] != '' && isset($col['name'])) { $ord[] = $col['name'] .' '. $col['ord']; @@ -284,6 +294,8 @@ class db_pager { // function _init() { + global $go_debug; + if ($this->ready == false ) { $sql = $this->_sql_gen(true); $result = db_query($sql, 'Error reading record set'); @@ -291,7 +303,20 @@ class db_pager { return false; $row = db_fetch_row($result); $this->rec_count = $row[0]; - $this->max_page = ceil($this->rec_count/$this->page_len); + $this->max_page = $this->page_len ? + ceil($this->rec_count/$this->page_len) : 0; + + if ($go_debug) { // FIX - need column name parsing, but for now: + // check if field names are set explicite in col def + // for all initially ordered columns + foreach ($this->columns as $col) { + if (isset($col['ord']) && $col['ord'] != '' + && !isset($col['name'])) { + display_warning("Result field names must be set + for all intially ordered db_pager columns."); + } + } + } $this->set_page(1); $this->ready = true; }