2008年12月4日星期四

Re: [fw-db] Help with joins and integrity check

$select->from(array('p'=>'product'))
->joinLeft(array(cp'=>'category_product'),
'cp.productId = p.productId',
array('field1','field2','...))
->where...

the 3th parameter of the join is where you define your fields you want to
select from the join table.

keith Pope-4 wrote:
>
> Hi,
>
> How do you select columns in a join, I am trying to join using
> setIntegrityCheck(true);
>
> $select = $this->select()->setIntegrityCheck(true);
> $select->from(array('p' => 'product'))
> ->joinLeft(array('cp' => 'category_product'),
> 'cp.productId = p.productId')
> ->where('cp.categoryId', $categoryId);
>
> gives:
>
> SELECT `p`.*, `cp`.* FROM `product` AS `p` LEFT JOIN
> `category_product` AS `cp` ON cp.productId = p.productId WHERE
> (cp.categoryId)
>
> But I don't want `cp`.* in the select so I can have integrity check true.
>
> Thx
>
> Keith
>
>


-----
http://www.phpscriptor.com/ http://www.phpscriptor.com/
--
View this message in context: http://www.nabble.com/Help-with-joins-and-integrity-check-tp20833562p20833646.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: