Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.11.5

Bug #359 toArray doesn't return links
Submitted: 2003-12-05 13:32 UTC
From: jstump Assigned:
Status: No Feedback Package: DB_DataObject
PHP Version: 4.3.3 OS: Debian GNU/Linux
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 30 + 12 = ?

 
 [2003-12-05 13:32 UTC] jstump
Description: ------------ While looping through a find() and adding getLinks() to each loop I was hoping to use toArray() to get a multidimensional array. Instead it appears that toArray() does not, in fact, return links. Reproduce code: --------------- $foo = new DataObjects_foo $foo->categoryID = 1 if($foo->find()) { $arr = array(); while($foo->fetch()) { $foo->getLinks(); $arr[] = $foo->toArray(); } } Expected result: ---------------- If my links.ini file had: [foo] categoryID = categories:categoryID You would think I'd get an array that had everything from foo and then [categoryID] => array('categoryID' => 1, 'name' =>'My category') but it doesn't. Actual result: -------------- It just returns the basic dataobject as an array with no link information. Putting a class in there instead via __clone() works as expected.

Comments

 [2003-12-12 01:47 UTC] alan_k
good point... - I'll have a look at this to see if it's possible.
 [2003-12-13 05:25 UTC] alan_k
Fixed In CVS. it should return the link in the array, and also convert those links into arrays. let me know if it works.
 [2004-01-18 19:01 UTC] seangirard at yahoo dot com
This fix isn't working for me. I'm probably doing something wrong, but I now get a 'call to non-object' error (about line 2576 i think) when I call toArray() after getting links. In this loop (from Data_Objects 1.4): foreach($this->_link_loaded as $k) { $ret[sprintf($format,$k)] = $this->$k->toArray(); } $this->$k isn't an object and that's the source of my error. Now, print_r() never has shown a value for _link_loaded on my Data Objects, which probably indicates I am goofing up somewhere, although my links do in fact seem to get loaded. I'm trying to whittle down a case which both a) has links and b) can sucessfully take a toArray() call, to figure out whether this is just a problem with my own code, but I haven't found one yet. On the off chance I'm not doing something wrong, and this is in fact a bug, I guess my suggestion would be to maybe check whether $this->$k is actually an object. I'll try to come up w/ an actual test case, but that's my feedback on what seems like a great addition to toArray() (my code to accomplish this same thing was significantly more convuluted and tied to my own data model)
 [2004-01-19 00:37 UTC] alan_k
will check it is cleared corectly..
 [2004-01-24 08:36 UTC] alan_k
should be fixed in 1.5.2 hopefully...