Re: issues movig to php5 (extending html_table)

From: Date: Mon, 03 Apr 2006 04:20:53 +0000
Subject: Re: issues movig to php5 (extending html_table)
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-23510@lists.php.net to get a copy of this message
Bonjour, Parent constructors are not called implicitly if the child class defines a constructor. In order to run a parent constructor, a an explicit call within the child constructor is required. Here your constructor does not call parent::HTML_Table(), therefore the proprieties specific to HTML_Table are not established. -- toggg j llarens wrote:
I beggining to test php 5.0.5. I get a error using an class that extends PEAR HTML_Table, and the error happends in HTML_Table, not in the inherited class. I could not determine the cause of the error. Can somebody guide me to documentation/hints regarding to code migration related to PEAR? Or PEAR can't be used with PHP5 ? this is the class HTML_DB_Table: <?php /* table from a query */ require_once ("HTML/Table.php"); class DB_HTML_Table extends HTML_Table { public $aColumnLinks = array(); public $aTableLinks = array(); public $sqlData; public $headers; public $isForm; public $aColTot=array(); public $aFilTot=array(); function DB_HTML_Table( $oResult, $attr, $headAttr=array(), $lForm=false ) {
     $this->sqlData = $oResult;
     HTML_Common::HTML_Common($attr);
} function addheaders( $attr=null ) {
     $aHeaders = $this->sqlData->tableInfo();
     $acHeaders = array();
     foreach( $aHeaders as $header ) {
        array_push( $acHeaders, $header["name"] );
     }
     $this->headers = $acHeaders;
     $this->addRow($acHeaders,$attr,"TH",true);
} function addData( $attr=null, $filas=null, $pntr=null ) {
     $i = is_null($filas) ? null : 0 ;
     // arma columnas de totales
     if(count($this->aColTot)){
        foreach($this->aColTot as $numCol){
           $this->aFilTot[$numCol]=0;
        }
     }
while ( $registro=$this->sqlData->fetchRow(DB_FETCHMODE_ORDERED,$i+$pntr) ) {
        if(count($this->aColTot)){
           foreach($this->aColTot as $numCol){
              $this->aFilTot[$numCol]+=$registro[$numCol];
           }
        }
        $i++;
        if ( !is_null($filas) and $i == $filas+1 ) {
           break;
        }
        $TRow="TD";
        $this->addRow($registro,$attr,$TRow,false);
     }
     if(count($this->aColTot)){
        $this->addRow($this->aFilTot,$attr,"TH",false);
     }
} function addColumnLink($url,$keyColumns,$label,$vars=array(),$attrs=null){
     $linkCol = array( "?" );
     for ( $x = 0; $x < $this->_rows-1; $x++ ) {
        $urlVars = "";
        foreach ( $vars as $key => $value ) {
           $urlVars.="&".$key."=".$value;
        }
        foreach( $keyColumns as $varName => $varValue ) {
           $urlVars.="&".$varName."=".$this->getCellContents($x+1,$varValue);
        }
        array_push( $linkCol, "<a href='".$url."?".$urlVars."' "." >".$label.
           "</a>" );
     }
     $this->addCol( $linkCol,$attrs );
} } ?> this code uses it, $dbc is an instance of PEAR::DB <?php /* this is not the complete code, nor in the class definition but is the minimal case */ require_once("DB_HTML_Table.php"); $oQ=&$dbc->query("select * from ciudad order by id"); $tb=new DB_HTML_Table($oQ); $tb->addHeaders(); $tb->addData(); $tb->display(); $oQ->free(); ?> and gives this error: Fatal error: call to a member function addRow() on a non-object in /usr/lib/php/HTML/Table.php on line 416 I have no clue __________________________________________________ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ¡gratis! ¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar


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