38 var
$prev =
'<code><<</code>';
47 var
$cache = 0; #secs to cache with CachePageExecute()
58 function
ADODB_Pager(&$db,$sql,$id = 'adodb', $showPageLinks = false)
62 $curr_page = $id.
'_curr_page';
63 if (!empty($PHP_SELF)) $PHP_SELF = htmlspecialchars($_SERVER[
'PHP_SELF']);
70 $next_page = $id.
'_next_page';
72 if (isset($_GET[$next_page])) {
73 $_SESSION[
$curr_page] = (integer) $_GET[$next_page];
75 if (empty($_SESSION[$curr_page])) $_SESSION[$curr_page] = 1; ## at first page
88 <a href=
"<?php echo $PHP_SELF,'?',$this->id;?>_next_page=1"><?php echo
$this->first;?></a>
91 print
"$this->first ";
103 <a href=
"<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() + 1 ?>"><?php echo
$this->next;?></a>
106 print
"$this->next ";
120 if (!$this->db->pageExecuteCountRows)
return;
124 <a href=
"<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->LastPageNo() ?>"><?php echo
$this->last;?></a>
127 print
"$this->last ";
136 $pages = $this->rs->LastPageNo();
137 $linksperpage = $this->linksPerPage ? $this->linksPerPage : $pages;
138 for($i=1; $i <= $pages; $i+=$linksperpage)
140 if($this->rs->AbsolutePage() >= $i)
146 $end = $start+$linksperpage-1;
147 $link = $this->
id .
"_next_page";
148 if($end > $pages) $end = $pages;
151 if ($this->startLinks && $start > 1) {
153 $numbers .=
"<a href=$PHP_SELF?$link=$pos>$this->startLinks</a> ";
156 for($i=$start; $i <= $end; $i++) {
157 if ($this->rs->AbsolutePage() == $i)
158 $numbers .=
"<font color=$this->linkSelectedColor><b>$i</b></font> ";
160 $numbers .=
"<a href=$PHP_SELF?$link=$i>$i</a> ";
163 if ($this->moreLinks && $end < $pages)
164 $numbers .=
"<a href=$PHP_SELF?$link=$i>$this->moreLinks</a> ";
165 print $numbers .
' ';
173 <a href=
"<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() - 1 ?>"><?php echo
$this->prev;?></a>
176 print
"$this->prev ";
188 include_once(ADODB_DIR.
'/tohtml.inc.php');
191 rs2html($this->rs,$this->gridAttributes,$this->gridHeader,$this->htmlSpecialChars);
192 $s = ob_get_contents();
204 if (!$this->rs->AtFirstPage()) {
206 $this->Render_Prev();
209 $this->Render_Prev(
false);
211 if ($this->showPageLinks){
212 $this->Render_PageLinks();
214 if (!$this->rs->AtLastPage()) {
215 $this->Render_Next();
216 $this->Render_Last();
218 $this->Render_Next(
false);
219 $this->Render_Last(
false);
221 $s = ob_get_contents();
230 if (!$this->db->pageExecuteCountRows)
return '';
231 $lastPage = $this->rs->LastPageNo();
232 if ($lastPage == -1) $lastPage = 1;
233 if ($this->curr_page > $lastPage) $this->curr_page = 1;
234 return "<font size=-1>$this->page ".$this->curr_page.
"/".$lastPage.
"</font>";
241 global $ADODB_COUNTRECS;
245 if ($this->db->dataProvider ==
'informix') $this->db->cursorType = IFX_SCROLL;
247 $savec = $ADODB_COUNTRECS;
248 if ($this->db->pageExecuteCountRows) $ADODB_COUNTRECS =
true;
250 $rs = $this->db->CachePageExecute($this->cache,$this->sql,$rows,$this->curr_page);
252 $rs = $this->db->PageExecute($this->sql,$rows,$this->curr_page);
253 $ADODB_COUNTRECS = $savec;
257 print
"<h3>Query failed: $this->sql</h3>";
261 if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage()))
277 function RenderLayout($header,$grid,$footer,$attributes=
'border=1 bgcolor=beige')
279 echo
"<table ".$attributes.
"><tr><td>",
281 "</td></tr><tr><td>",
283 "</td></tr><tr><td>",
285 "</td></tr></table>";
rs2html(&$rs, $ztabhtml=false, $zheaderarray=false, $htmlspecialchars=true, $echo=true)