dataObject multiple links from a column
| From: | Didier Galland | Date: | Sun, 11 Jan 2004 01:53:53 +0000 |
| Subject: | dataObject multiple links from a column | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-10098@lists.php.net to get a copy of this message | ||
Hi
I cannot manage to link a dataObject with more than one table from a single
column, either by getLinks() or by joinAdd(). The only way for me is to
manually make the link with $linkedObject =
$obj->getLink('col','table','col') and work with the such created
object.
The syntax of dbname.links.ini for multiple links as described in the doc
(car_id.partnum = part_numbers:car_id line in [sales] section) don't works
for me
(http://pear.php.net/manual/en/html/package.database.db-dataobject.intro-rel
ations.html)
Here is my code, do I make something wrong ??? Thanks for any help !
======= dbname.links.ini =========
[marker_category_xref]
marker_id = marker:marker_id
marker_id.smc = marker_commercial_smc:marker_id
==== end of dbname.links.ini ======
DB_DataObject::DebugLevel(1);
$mcx = DB_DataObject::factory('marker_category_xref');
$mcs = DB_DataObject::factory('marker_commercial_smc');
$mcx->category_id = $category_id;
$mcs->joinAdd($mcx);
$dbg = array();
$mcs->find();
while ($mcs->fetch()) {
$dbg[]=$mcs;
}
Result :
__find:
QUERY: SELECT * FROM marker_commercial_smc INNER JOIN marker_category_xref
ON marker_category_xref.marker_id.smc=marker_commercial_smc.marker_id WHERE
marker_category_xref.category_id = '2f8edc5e7dc6a65839672545d7ff3a43'
SENT: SELECT * FROM marker_commercial_smc INNER JOIN marker_category_xref ON
marker_category_xref.marker_id.smc=marker_commercial_smc.marker_id WHERE
marker_category_xref.category_id = '2f8edc5e7dc6a65839672545d7ff3a43'
ERROR: DB Error: unknown error
__find: CHECK autofetchd
__find: DONE