Re: DB_Dataobject and complex joins
| From: | Alan Knowles | Date: | Thu, 08 Dec 2005 02:25:12 +0000 |
| Subject: | Re: DB_Dataobject and complex joins | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-22178@lists.php.net to get a copy of this message | ||
Something like this... (check the source for exact details..)
.. add to your extended class...
function createMySpecialJoin()
{
$this->_join = "
table1 AS a LEFT JOIN table2 AS b
ON a.field1 = b.field1
AND a.field2 = b.field2
AND a.field3 = b.field3
";
}
Regards
Alan
On Mon, 2005-12-05 at 10:56 -0300, Hugo W. Alves wrote:
> Hi People!
>
> How I do this using DB_DataObject functions?
>
> select *
> from table1 as a
> left join table2 as b
> on a.field1 = b.field1 and a.field2 = b.field2 and a.field3 = b.field3
>
> my db.links.ini:
>
> [table1]
> field1 = table2:field1
> field2 = table2:field2
> field3 = table2:field3
>
> the call:
>
> $F = DB_DataObject::factory('table1');
> $C = DB_DataObject::factory('table2');
> $F->joinAdd($C);
> $F->find();
>
> the query result:
>
> SELECT * FROM table1 INNER JOIN table2 ON table1.field1=table2.field1
>
> Where are the others releted fields?
>
>
>
>
> ---------------------------------
> Yahoo! doce lar. Faça do Yahoo! sua homepage.