CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Navigation Implementation

Print topic Send  topic

Author Message
Keith
Posted: 06/16/2003, 9:51 PM

How is navigation implemented in Codecharge generated PHP code?

What I mean is, how does it manage the database when it comes to breaking up the records in a query into multiple pages.

Lets say if you hit page 2 of 4 and there are 100 records per page, does the code scan through 100 records for page 1 until it gets to record 101 of page 2 and then start displaying?

If you hit page 3 afterwards, does all this happen again? WHat is the mechanism used? Is it efficient?
rrodgers
Posted: 06/17/2003, 8:40 AM

You don't say what tools you are using. CC or CCS?

In CCS
It doesn't look particulaly efficient but this is probably a condition of needing to support all the different DB's that are supported. I know at least with ADO you can use PageSize and AbsolutePage to do this.

Of course the good thing about CCS is you can modify this code to handle the page display as you like. If your DB supports a better method you can code it.

rob

=======================

In PHP
function MoveToPage($Page)
{
if($this->RecordNumber == 0 && $this->PageSize != 0 && $Page != 0)
while($this->RecordNumber < ($Page - 1) * $this->PageSize && $this->next_record())
$this->RecordNumber++;
}

In ASP

Function MoveToPage(Page)
Dim PageCounter
Dim RecordCounter

If Recordset.State = adStateOpen Then
PageCounter = 1
RecordCounter = 1
While NOT Recordset.EOF AND PageCounter < Page
If RecordCounter MOD Command.PageSize = 0 Then
PageCounter = PageCounter + 1
End If

RecordCounter = RecordCounter + 1
Recordset.MoveNext
Wend
End If
Command.ActivePage = PageCounter
End Function
Keith
Posted: 06/17/2003, 10:37 AM

I am using CCS 2.1

I am confused with the following code. It looks like it just increments an internal class variable : RecordNumber. How does it impact the database? Where is it doing database scans through the result set? Thanks.

function MoveToPage($Page)
{
if($this->RecordNumber == 0 && $this->PageSize != 0 && $Page != 0)
while($this->RecordNumber < ($Page - 1) * $this->PageSize && $this->next_record())
$this->RecordNumber++;
}
rrodgers
Posted: 06/17/2003, 11:41 AM

this->next_record())

Follow the code and this bit should be moving the record set pointer.

rob
Keith
Posted: 06/17/2003, 12:05 PM

Oh gawd, next_record actually fetches the entire row and throws it away.
THis can't be good. What if we have 80 pages of 100 rows each. Each page access
will cause a scan/fetch through 1->n rows before it gets to the page.

Can someone suggest something more efficient in PHP and PostGreSQL and ORacle.
Thanks!!

P.S. How about just incrementing this->Row and then do a fetch? Is there a way to increment this at the server without fetching?

----

function next_record() {
$this->Record = @pg_fetch_array($this->Query_ID, $this->Row++);

$this->Error = pg_ErrorMessage($this->Link_ID);
$this->Errno = ($this->Error == "")?0:1;

$stat = is_array($this->Record);
if (!$stat && $this->Auto_Free) {
pg_freeresult($this->Query_ID);
$this->Query_ID = 0;
}
return $stat;
}

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.