Re: object in object

From: Date: Tue, 26 Sep 2000 21:01:34 +0000
Subject: Re: object in object
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-3122@lists.php.net to get a copy of this message
As far as I know the constructor function must have the same name of the class, may be this is the problem with your classes. Jayme. http://www.conex.com.br/jjeffman -----Mensagem Original----- De: Lajtos Máté <lajtos.mate@komar.hu> Para: PHPDB <php-db@lists.php.net> Enviada em: terça-feira, 26 de setembro de 2000 18:46 Assunto: [PHP-DB] object in object > Hi All, > > I've got a problem with my own classes. I've got the following code: > fld is a small class for storing field info. tbl class contains an array > (called 'flds') of 'fld's. > > class fld { > var $len,$typ; > > function setattrs($l,$t) > { > $this->len=$l; > $this->typ=$t; > > } > > } > > class tbl { > > var $flds; > > function create($tlname) > { > > $conn=ocilogon("user","pw","tns"); > $sql="select * from $tlname"; > $stmt=ociparse($conn,$sql); > ociexecute($stmt); > $numcols=ocinumcols($stmt); > for($i=1;$i<=$numcols;$i++) > { > $rt=new fld; > > $rt->setattrs(ocicolumnsize($stmt,$i),ocicolumntype($stmt,$i)); > $this->flds[ocicolumnname($stmt,$i)]=$rt; > } > } file://end function 'create' > > }//end class def > > > > If I say: > $h=new tbl("tablename"); > print($h->flds['fieldname']->typ > I've got a parse error. > > But: > $h=new tbl("tablename"); > $f=$h->flds['fieldname']; > print($f->typ); > is working fine. > > I just like to know whether I do something wrong or PHP doesn't support > this way of referring to properties > > > Thanks in advance, > Máté Lajtos > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.db (#3122) next »