Ver Mensaje Individual
  #4 (permalink)  
Antiguo 05/02/2009, 10:19
AeroCross
 
Fecha de Ingreso: marzo-2008
Mensajes: 73
Antigüedad: 16 años, 1 mes
Puntos: 0
Respuesta: ¿Instanciar un objeto dentro de otro y usarlo?

Código php:
Ver original
  1. class paging
  2.     {
  3.     public $self;
  4.     public $pagenum;
  5.     public $perpage;
  6.     public $maxpages;
  7.     public $page;
  8.    
  9.         function paging($sqlcol, $sqltable, $display_per_page)
  10.         {
  11.                 $this->self = $_SERVER["PHP_SELF"];
  12.                
  13.                 if(!isset($idConn))
  14.                 {
  15.                         $idConn = new databaseManager(DB_SERVER, DB_USER, DB_PASSWORD, DB_DATABASE);
  16.                 }
  17.                    
  18.                 $idConn->query("SELECT COUNT('$sqlcol') FROM '$sqltable'");
  19.                 $this->pagenum = $idConn->getSelected();
  20.                 $this->perpage = $display_per_page;
  21.                
  22.                 if (empty($start)): $start = 0; endif;
  23.                
  24.                 $this->maxpages = $this->pagenum / $this->perpage;
  25.                 $this->page = ceil($start / $this->perpage) + 1;
  26.                
  27.                 if (isset($_GET["page"])): $this->page = $_GET["page"]; endif;
  28.         }
  29.        
  30.         function nextlink()
  31.         {
  32.             if ($this->pagenum < $this->maxpages)
  33.             {
  34.                 $page = $this->pagenum + 1;
  35.                 return '<a href="'.$this->self.'?page='.$this->page.'" title="Siguiente">Siguiente</a>';
  36.             }
  37.             else
  38.             {
  39.                 return FALSE;
  40.             }
  41.         }
  42.        
  43.         function prevlink()
  44.         {
  45.             if ($this->pagenum > 1)
  46.             {
  47.                 $page = $this->pagenum - 1;
  48.                 echo '<a href="'.$this->self.'?page='.$this->page.'" title="Anterior">Anterior</a>';
  49.             }
  50.             else
  51.             {
  52.                 return FALSE;
  53.             }
  54.         }
  55.     }

Claro, esto está todavía en construcción, no encuentro un buen script de paginación así qeu ando intentando el mío =)

Última edición por AeroCross; 05/02/2009 a las 10:22 Razón: Limpieza de código.