Re: DataObjects

From: Date: Tue, 20 May 2003 07:31:59 +0000
Subject: Re: DataObjects
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-5448@lists.php.net to get a copy of this message
If our little employee belongs to a number of departments (1:N relationship) does _dept become an array of objects? Chee On Tue, 2003-05-20 at 14:34, mitchell perilstein wrote: > On Mon, 2003-05-19 at 17:35, Barry Steele wrote: > > Oh, and on another issue, if I have a linked object (eg Employee - > > Dept) > > > > how do I reference Dept details within the Employee object after a > > get_link() ? > > > > for example > > > > emp = new DataObject_Employee; > > > > emp->get(123); > > emp->get_links(); > > print ($emp->dept->deptName); ??? - I tried thi sonce and failed and > > could figure it out > > You were close... Try $emp->_dept->deptName. $emp->dept is the > key member in your object, $emp->_dept gets filled in by the getLink() > or getLinks() call. > > Hint for debugging: Do a print_r($emp) before and after your > $emp->getLinks(). If things are working, you will not see a _dept > member before and you will see a full one after. > > Another hint for debugging: > > $emp->debugLevel(1); // debug on > // do stuff here .... > $emp->debugLevel(0); // debug off > > hth, -- Barry Steele <barry@hpfm.biz> hpfm

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