object in object

From: Date: Tue, 26 Sep 2000 21:46:24 +0000
Subject: object in object
Groups: php.db 
Request: Send a blank email to php-db+get-3091@lists.php.net to get a copy of this message
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; } } //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

« previous php.db (#3091) next »