<?php
+/**********************************************************************
+ Copyright (C) FrontAccounting, LLC.
+ Released under the terms of the GNU General Public License, GPL,
+ as published by the Free Software Foundation, either version 3
+ of the License, or (at your option) any later version.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
//
// Controler part of database table pager with column sort.
// To display actual html object call display_db_pager($name) inside
}
$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'];
//
function _init()
{
+ global $go_debug;
+
if ($this->ready == false ) {
$sql = $this->_sql_gen(true);
$result = db_query($sql, 'Error reading record set');
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;
}