Re: DB_DataObject::getLinks() totally broken?
| From: | Alan Knowles | Date: | Sat, 06 Dec 2003 03:44:51 +0000 |
| Subject: | Re: DB_DataObject::getLinks() totally broken? | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-24218@lists.php.net to get a copy of this message | ||
getlinks only really supports 1:1 mapping, i'm gestting you where expecting an array.. e.g 1:Many
it is feasible to use get links for 1:Many
$x = $comments->getLink('linked_column');
$ar=array($x->__clone());
while($x->fetch()) {
$ar[] = $x->__clone();
}
Regards
Alan
Joe Stump wrote:
I'm beating my head against the wall on this one ... Here is my code:-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com$comments = & new DataObjects_Blog_comments(); $comments->entryID = $entry->contentID; if($comments->find()) { $arr = array(); while($comments->fetch()) { $comments->getLinks();echo '<pre>'; print_r($comments); echo '</pre>'; $arr[] = $comments->__clone(); }echo '<pre>'; print_r($arr); echo '</pre>';$this->setData('comments',$arr); }And here is my output: dataobjects_blog_comments Object ([_DB_DataObject_version] => 1.3 [__table] => blog_comments [N] => 2 [_database_dsn] => [_database_dsn_md5] => 2c76ae5381cb31453eccd4e0761fd402 [_database] => josephstump [_DB_resultid] => 2 [_link_loaded] => [_join] => [_lastError] => [contentID] => 479257226 [entryID] => 291345797 [name] => Joseph Stump [email] => joe@joestump.net [url] => [comments] => asdf asdf asdf [_contentID] => dataobjects_content Object ( [_DB_DataObject_version] => 1.3 [__table] => content [N] => 13 [_database_dsn] => [_database_dsn_md5] => 2c76ae5381cb31453eccd4e0761fd402 [_database] => josephstump [_DB_resultid] => 3 [_link_loaded] => [_join] => [_lastError] => [contentID] => 851626192 [userID] => 133465235 [posted] => 1070225887 [lastUpdate] => 1070225887 [available] => 1 [mime] => JxAdminBlogCategories [title] => Work [module] => blog )) Here is my relevant links.ini def: [blog_comments] contentID = content:contentID Am I totally off base in assuming that the link (contentID in this case) should be the same in both my primary class ($comments) and my link class ($comments->_contentID)? It just grabs the first record in the table and slaps it in there. Should it be doing this instead: "SELECT * FROM content WHERE contentID=$comments->contentID" --Joe -- Joe Stump <joe@joestump.net> http://www.joestump.net "Label makers are proof God wants Sys Admins to be happy."