Re: Table joining with DB_DataObject

From: Date: Wed, 19 May 2004 13:06:19 +0000
Subject: Re: Table joining with DB_DataObject
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-12603@lists.php.net to get a copy of this message
Quoting Norbert Mocsnik <pear-general@mocsnik.hu>:
Hello Ian, If you have no special reason for using join, I'd do this:
My reason is server load. I want to do the following... select * from a, b where a.username = b.username and b.attribute='password'. I am concerned that the method below will execute a seperate SQL query for each and every record in 'a'. Kind Regards, Ian <post left for history reasons!>
[a] userName = b.username
$a =& DB_DataObject::factory('a'); if ($a->find()) {
    while ($a->fetch()) {
        $a->getLinks();
        print_r($a);
    }
} Regards, Norbert Ian P. Christian wrote:
Hello all! I'm having issues with getting tables to join with DB_Dataobject. I have a two tables, A and B table a id (key) username table b id (key) username attribute I have a database.links.ini with the following in it... [a] userName = b.username and the following code... $a =& DB_DataObject::factory('a'); $b =& DB_DataObject::factory('b'); $b->Attribute = 'Password'; $a->joinAdd($b); $a->find(); $a->fetch(); Var_Dump::display($a); The error I am getting is 'joinAdd: b has no link with a' Can anyone see what I'm doing wrong? kind Regards, Ian


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