/** * Constructor. * Initialize the DBRowIterator * @param $records object ADO record set * @param $dao object DAO class for factory * @param $functionName The function to call on $dao to create an object */ function __construct(&$records, $idFields = array()) { parent::__construct(); $this->idFields = $idFields; if (!$records || $records->EOF) { if ($records) { $records->Close(); } $this->records = null; $this->wasEmpty = true; $this->page = 1; $this->isFirst = true; $this->isLast = true; $this->count = 0; $this->pageCount = 1; } else { $this->records =& $records; $this->wasEmpty = false; $this->page = $records->AbsolutePage(); $this->isFirst = $records->atFirstPage(); $this->isLast = $records->atLastPage(); $this->count = $records->MaxRecordCount(); $this->pageCount = $records->LastPageNo(); } }
/** * Constructor. * @param $theArray array The array of items to iterate through * @param $totalItems int The total number of items in the virtual "larger" array * @param $page int the current page number * @param $itemsPerPage int Number of items to display per page */ function __construct(&$theArray, $totalItems, $page = -1, $itemsPerPage = -1) { parent::__construct(); if ($page >= 1 && $itemsPerPage >= 1) { $this->page = $page; } else { $this->page = 1; $this->itemsPerPage = max(count($this->theArray), 1); } $this->theArray =& $theArray; $this->count = $totalItems; $this->itemsPerPage = $itemsPerPage; $this->wasEmpty = count($this->theArray) == 0; reset($this->theArray); }
/** * Constructor. * @param $theArray array The array of items to iterate through * @param $page int the current page number * @param $itemsPerPage int Number of items to display per page */ function __construct(&$theArray, $page = -1, $itemsPerPage = -1) { parent::__construct(); if ($page >= 1 && $itemsPerPage >= 1) { $this->theArray = $this->array_slice_key($theArray, ($page - 1) * $itemsPerPage, $itemsPerPage); $this->page = $page; } else { $this->theArray =& $theArray; $this->page = 1; $this->itemsPerPage = max(count($this->theArray), 1); } $this->count = count($theArray); $this->itemsPerPage = $itemsPerPage; $this->wasEmpty = count($this->theArray) == 0; reset($this->theArray); }