Page 2 of 2

Posted: Thu Nov 02, 2006 1:05 pm
by timvw
Burrito wrote: what advantage do you gain by having them in different objects rather than properties?
With different objects you can override *all* the methods and get a completely different presentation of the paginated item... (And example of why that can be beneficial can be found here.)

Posted: Thu Nov 02, 2006 1:51 pm
by Burrito
I hit the link...and the first thing that caught my eye was the example names you selected... 8O

8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O

Posted: Thu Nov 02, 2006 3:16 pm
by Chris Corbyn
Ha yeah that genious :)

Posted: Thu Nov 02, 2006 4:14 pm
by timvw
the fact that those names sound familiar to you says enough ;)

Posted: Thu Nov 02, 2006 4:16 pm
by Burrito
timvw wrote:the fact that those names sound familiar to you says enough ;)
ummm...yeah, I heard them from my uhh umm friend.

Posted: Thu Nov 02, 2006 4:20 pm
by Christopher
The code that TmVW uses is very similar to mine -- because the ideas went into and came out of the same discussion (code here). :)

The thing about pagers is that they decompose pretty quickly into a bunch of classes if you start to refactor them. The ususal things: request processor, calculations, datasource, HTML (or other) output. The current Skeleton code has pager code extended from that discussion that does things like recalc and resume when returning from sub-pages of the list, and database independence, etc. I also end up having the Pager just do the basics and have the View build the links exactly how they are specificed by the design.

Posted: Thu Nov 02, 2006 4:26 pm
by jayshields
Burrito wrote:I hit the link...and the first thing that caught my eye was the example names you selected... 8O

8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O
Yeah, but shouldn't it be:

Code: Select all

$data = array(
        array(‘surname’ => ‘Jameson’, ’forename’ => ‘Jenna’),
        array(‘surname’ => ‘Banks’, ’forename’ => ‘Briana’),
        array(‘surname’ => ‘Giovanni’, ’forename’ => ‘Aria’),
        array(‘surname’ => ‘Rush’, ’forename’ => ‘Daniella’),
        array(‘surname’ => ‘Flowers’, ’forename’ => ‘April’)
);

Posted: Thu Nov 02, 2006 4:28 pm
by Burrito
jayshields wrote:
Burrito wrote:I hit the link...and the first thing that caught my eye was the example names you selected... 8O

8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O 8O
Yeah, but shouldn't it be:

Code: Select all

$data = array(
        array(‘surname’ => ‘Jameson’, ’forename’ => ‘Jenna’),
        array(‘surname’ => ‘Banks’, ’forename’ => ‘Briana’),
        array(‘surname’ => ‘Giovanni’, ’forename’ => ‘Aria’),
        array(‘surname’ => ‘Rush’, ’forename’ => ‘Daniella’),
        array(‘surname’ => ‘Flowers’, ’forename’ => ‘April’)
);
hmm...I wouldn't know :D

Posted: Thu Nov 02, 2006 4:33 pm
by Chris Corbyn
OK I'm off to... ermm... do some research around these names before I go to bed...

Posted: Fri Nov 03, 2006 6:51 pm
by pedrotuga
JayBird wrote:Hmmm...weird, I'm sure someone posted a reply when i checked this morning.

Anyway...he was saying that it may be better to just COUNT() the rows in the DB instead of returning the entire resultset. Well, this is something i was talking to JCart about last night.

To do this, we were think of doing something along the lines of (as suggested by Aborint in a thread a while ago)
It was me... i thought this was the code snipets forum and i made that comment. When i saw it was the code critique i thoght my comment was not complete enough to keep and deleted it... i guess i should have kept it.
Anyway... cpliting the query using the front as a separator to explode() should do it... i come in 5 minutes ;)

Posted: Fri Nov 03, 2006 7:09 pm
by pedrotuga
hey there.. here i am again...

i made some chages but i didnt test them yet.

I replaced this:

Code: Select all

function totalResults()
	{
			$this->result = mysql_query($this->query);
			$this->totalResults = mysql_num_rows($this->result);
		   
			if($this->totalResults != 0)
			{
					$this->maxPage = ceil(($this->totalResults / $this->perPage));
			}
	}
By this:

Code: Select all

function totalResults()
	{		
			$this->query = str_replace ( "from", "FROM", $this->query );
			$this->query_pieces=explode("FROM");
			$this->query_test = "select count(*) from ".$this->query_pieces[1];
			$this->result = mysql_query($this->query_test);
			$this->totalResults = mysql_result($this->result,0);
		   
			if($this->totalResults != 0)
			{
					$this->maxPage = ceil(($this->totalResults / $this->perPage));
			}
	}
this wont work with subqueries as they have more than one ocorrence of "from".
Also, a dummy doubt i never got solved... when should i use the %delimiters% on str_replace??? and why?