Re: DataObject::getLinks() usage

From: Date: Tue, 25 Feb 2003 04:31:50 +0000
Subject: Re: DataObject::getLinks() usage
References: 1  Groups: php.pear.general php.pear.general 
Request: Send a blank email to pear-general+get-3937@lists.php.net to get a copy of this message
Mike Carter wrote:
Hi, Done a search in the mailing list archive but found nothing which solves a problem I have. I've created all my database tables in the relevant format as stated in the pear.php.net docs for the DB_DataObject. Agh - unfortunatly I'm still waiting for peardoc2 to be released - the updated docs
http://devel.akbkhome.com/peardoc2/packages.database.db-dataobject.relations.html Has been changed to this "Currently automated links are supported by column naming conventions, this feature is depreciated in favour of using the links.ini files. As this offers a more flexible and clearer way of performing these operations." It doesnt actually say that the program had to do alot of extra work to handle the naming convention.. - and it added just a little too much hidden magic - making the code a little more difficult to comprehend.
I have a table with a field named 'traveldestination_id'. I assume the DataObject class should allow me to link this to the table traveldestination.id field? My question is exactly where do I use the getLinks() method? From the documentation it appears that I do *not* have to waste time creating a links .ini file either if I use getLinks(), rather than getLink() - is this right? you can use getLink() without an ini file
eg. $this->getLink('thisColumnName','otherTable','otherTableColumnName')
I set up my query, call find, and loop through the results (there are multiple results). Here's my test code:- function getVaccinations($destinationId) { $db = new DO_Traveldisdestimmrec; $db->traveldestination_id = $destinationId; $db->find(); while ($db->fetch()){ add it in here..
$db->getLinks();
print_r($db);echo '<br><br>'; } } The fetched results never seem to have the embedded object of the traveldestination table. It just has the traveldestination_id = '2'. Why? From the first fetch() call I get... object(do_traveldisdestimmrec)(19) { ["_DB_DataObject_version"]=> string(3) "1.0" ["__table"]=> string(19) "traveldisdestimmrec" ["N"]=> int(1) ["_database_dsn"]=> string(0) "" ["_database_dsn_md5"]=> string(32) "963e070b0532b2a12e97394826f880f9" ["_database"]=> string(3) "pma" ["_condition"]=> string(0) "" ["_group_by"]=> string(0) "" ["_order_by"]=> string(0) "" ["_limit"]=> string(0) "" ["_data_select"]=> string(1) "*" ["_DB_resultid"]=> int(1) ["_link_loaded"]=> bool(false) ["_join"]=> string(0) "" ["_lastError"]=> bool(false) ["traveldisease_id"]=> string(1) "1" ["traveldestination_id"]=> string(1) "2" ["travelimmrec_id"]=> string(1) "2" ["id"]=> string(2) "14" } The current online documentation is very patchy at times - who is responsible for keeping it up to date?
Me :) - any help welcome ... - Hopefully when peardoc2 goes live we will also get user comments - which should help alot - you know the clasic problem - the first person author always misses stuff that is obvious to someone comming in cold.. PS. the 0.15 fixed a rather major bug on delete() not using primary keys.. Regards Alan
Bye,


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