Re: RE: DataObjects with Paged

From: Date: Sat, 26 Apr 2003 12:38:00 +0000
Subject: Re: RE: DataObjects with Paged
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-5075@lists.php.net to get a copy of this message
I use the following code that works well for most situations: $limit = PSG_RES_PER_PAGE; require_once PSG_ENT_DIR . '/Property.php'; $output->template = 'wsProperty.html'; $propertyList = & new DataObjects_Property; $propertyList->owner_id = Session::get('SESSION_UID'); $totalNumRows = $propertyList->count(); $propertyList->limit($input->from, $limit); $result = $propertyList->find(); if($result > 0) {
    $property = array();
    while ($propertyList->fetch()) {
        $propertyList->getLinks();
        $property[] = $propertyList->__clone();
    }
    $data = DB_Pager::getData($input->from, $limit, $totalNumRows, $maxpages);
    //	don't show pager if less than a pagefull
    if($totalNumRows <= $limit)
        $output->pager = false;
    else
        $output->pager = (object)$data;
} $output->propertyList = $property; The $output->pager property is set to false if there are fewer results than your paging limit, otherwise it holds the Pager object. Using Flexy template, or any template system for that matter, you can dynamically include a 'pager.html' template if you have say more than 10 results, 10 being your res per page. cheers Demian The Php_kid wrote:
Sorry, I forgot to clear that I'm looking for a example of DataObject with PEAR::DB_Pager package. Thanks again. Mac -> -> Hi Alan, -> -> I've saw your example, but it is a bit complex to me. -> Have you a more simpler example about how to use -> DataObjects with Paged ? -> -> Thank you very much ! -> -> Mac -> ...The PhP_KiD -> -> -> -> -----Mensaje original----- -> -> De: Alan Knowles [mailto:alan@akbkhome.com] -> -> Enviado el: Jueves, 24 de Abril de 2003 22:04 -> -> Para: The Php_kid -> -> CC: pear-general@lists.php.net -> -> Asunto: Re: DataObjects with Paged -> -> -> -> -> -> this has an example using Pager_Sliding -> -> -> -> http://www.akbkhome.com:81/svn/akpear/HTML_FlexyFramework/FlexyFr -> -> amework/DatabaseBrowse.php -> -> -> -> -> -> Regards -> -> Alan -> -> -> -> The Php_kid wrote: -> -> > Hi DataObject users !!! -> -> > -> -> > How can I do to use DataObject in order -> -> > to get Paged results ? -> -> > -> -> > Have you an example ? -> -> > -> -> > Thank you ! -> -> > -> -> > -> -> > Mac -> -> > ...The PhP_KiD -> ->


« previous php.pear.general (#5075) next »