osdir.com
mailing list archive

Subject: Re: Zend_Paginator and Zend_Db_Table_Select objects - msg#00132

List: php.zend.framework.mvc

Date: Prev Next Index Thread: Prev Next Index
I seem to have lost the ability to post issues in the issue tracker (or am having a really hard time finding the right link to click on). Are members of the "Confluence-users" group allowed to post new issues?

-Hector

Jurriën Stutterheim wrote: Hi Hector,

Could you report both bugs on the issue tracker please? You'll be glad to hear that the first bug is known and it's being worked on. The goal is to have it fixed before the official ZF 1.6 release.

On Jul 22, 2008, at 22:31 , Hector Virgen wrote:
Hello,

I just noticed the new components on the online manual and decided to try out the new paginator. Very nice!

I found a couple small bugs that you might want to have a look at:

1) An exception is thrown when using a Zend_Db_Table_Select object: "No table has been specified for the FROM clause". To get around this, I had to call from() on the select object (which is redundant for Zend_Db_Table_Select).

<?php

$table = new MyTable();

$select = $table->select()
->from($table) // required for paginator?
;

$paginator = Zend_Paginator::factory($select);

?>

2) The paginator will break if you set the current page number before setting the item count per page. It seems that setting the page number executes the query to retrieve the items. Is this intentional?

<?php

$page = 1;
$itemsPerPage = 5;

// Not working
$paginator = Zend_Paginator::factory($select);
$paginator->setCurrentPageNumber($page);
$paginator->setItemCountPerPage($itemsPerPage);
$items = $paginator->getItems();  // Incorrectly returns 10 items (the default count per page)

// This works
$paginator = Zend_Paginator::factory($select);
$paginator->setItemCountPerPage($itemsPerPage);
$paginator->setCurrentPageNumber($page); // Must be done last
$items = $paginator->getItems();  // Correctly returns 5 items

?>

Otherwise, the paginator is working nicely and I plan to replace my current poor-boy's paginator with the Zend one very soon :)

-Hector

Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: Zend_Paginator and Zend_Db_Table_Select objects

Hi Hector,Could you report both bugs on the issue tracker please?You'll be glad to hear that the first bug is known and it's being worked on. The goal is to have it fixed before the official ZF 1.6 release.On Jul 22, 2008, at 22:31 , Hector Virgen wrote: Hello, I just noticed the new components on the online manual and decided to try out the new paginator. Very nice! I found a couple small bugs that you might want to have a look at: 1) An exception is thrown when using a Zend_Db_Table_Select object: "No table has been specified for the FROM clause". To get around this, I had to call from() on the select object (which is redundant for Zend_Db_Table_Select). <?php $table = new MyTable(); $select = $table->select() ->from($table) // required for paginator? ; $paginator = Zend_Paginator::factory($select); ?> 2) The paginator will break if you set the current page number before setting the item count per page. It seems that setting the page number executes the query to retrieve the items. Is this intentional? <?php $page = 1; $itemsPerPage = 5; // Not working $paginator = Zend_Paginator::factory($select); $paginator->setCurrentPageNumber($page); $paginator->setItemCountPerPage($itemsPerPage); $items = $paginator->getItems();  // Incorrectly returns 10 items (the default count per page) // This works $paginator = Zend_Paginator::factory($select); $paginator->setItemCountPerPage($itemsPerPage); $paginator->setCurrentPageNumber($page); // Must be done last $items = $paginator->getItems();  // Correctly returns 5 items ?> Otherwise, the paginator is working nicely and I plan to replace my current poor-boy's paginator with the Zend one very soon :) -Hector

Next Message by Date: click to view message preview

Re: Best practices in a thin-controller application

On Tue, Jul 22, 2008 at 3:26 PM, David Mintz <david-dMffkYQFJ3MKxoK4Ny/0iQ@xxxxxxxxxxxxxxxx> wrote: > Which brings me to another question, maybe sort of OT. If your model's > constructor requires an id parameter, how do you instantiate a "blank" > object to be populated with data provided by the user and then -- excuse me > for thinking database -- inserted into a table? I am thinking of RDMSes that > have auto-incrementing.You find out the id after the insert. Good question. In my actual code (as opposed to the examples posted here) the constructor allows a null ID for the reasons you've described. Actually my real constructor allows a wide variety of "ID" parameters, some of which might be considered cheating :) For example, this is allowed: [code] $table = new Travel_Table_Trips(); $row = $table->find(15)->current(); $tripModel = new Travel_Trip($row); // ...something smells funny... [/code] I allow this for convenience and performance reasons, since there are occasionally cases where the code instantiating the Trip object has already, for one reason or another, pulled that Trip object's associated row from the underlying database table. The problem, of course, is that neither Travel_Trip nor Travel_Agent is supposed to expose its database dependence to the outside world...all of the persistence stuff should happen inside the "black box." For instance, I have a Travel_Agent class whose job it is to find and return lists of Trips. Internally, it does this by referencing the same database table that internally backs the Travel_Trip module: [code] class Travel_Agent { public function findTripsByCountry($country) { $table = new Travel_Table_Trips(); $select = $table->select(); $select->where('country = ?', $country); $rowset = $table->fetchAll($select); $list = new Travel_TripList(); foreach ($rowset as $row) { $list->add(new Travel_Trip($row)); } } } [/code] See why it's helpful to be able to construct the Travel_Trip object from the row? It saves Travel_Trip from having to reload an already-loaded row from the database. It does so, however, at the expense of Travel_Agent being aware of the fact that Travel_Trip is backed by a database table. Comments? Is there a way to keep from having to reload the row without exposing Travel_Trip's database dependency? Thanks! Adam

Previous Message by Thread: click to view message preview

Re: Zend_Paginator and Zend_Db_Table_Select objects

Hi Hector,Could you report both bugs on the issue tracker please?You'll be glad to hear that the first bug is known and it's being worked on. The goal is to have it fixed before the official ZF 1.6 release.On Jul 22, 2008, at 22:31 , Hector Virgen wrote: Hello, I just noticed the new components on the online manual and decided to try out the new paginator. Very nice! I found a couple small bugs that you might want to have a look at: 1) An exception is thrown when using a Zend_Db_Table_Select object: "No table has been specified for the FROM clause". To get around this, I had to call from() on the select object (which is redundant for Zend_Db_Table_Select). <?php $table = new MyTable(); $select = $table->select() ->from($table) // required for paginator? ; $paginator = Zend_Paginator::factory($select); ?> 2) The paginator will break if you set the current page number before setting the item count per page. It seems that setting the page number executes the query to retrieve the items. Is this intentional? <?php $page = 1; $itemsPerPage = 5; // Not working $paginator = Zend_Paginator::factory($select); $paginator->setCurrentPageNumber($page); $paginator->setItemCountPerPage($itemsPerPage); $items = $paginator->getItems();  // Incorrectly returns 10 items (the default count per page) // This works $paginator = Zend_Paginator::factory($select); $paginator->setItemCountPerPage($itemsPerPage); $paginator->setCurrentPageNumber($page); // Must be done last $items = $paginator->getItems();  // Correctly returns 5 items ?> Otherwise, the paginator is working nicely and I plan to replace my current poor-boy's paginator with the Zend one very soon :) -Hector

Next Message by Thread: click to view message preview

Can't log into Zend's Websites

Hi, For remember to Matthew, i've experienced since some months an issue on the wiki and the JIRA : I can't log. When I enter my true informations (login, pass) i'me redirect to the login page without any error messages but not loggued ! When i'm doing it with wrong informations, i have error message. ****
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by