0

I am new in yii framework. and I want to know about take date from two table with join.

I try many times but not solve.

I know the join and know i use it manually. not yii standard.

I want to know How can join two table in yii framework with standard.

4

2 回答 2

0

In yii You want to use join code in $criteria object

e.g.

$criteria=new CDbCriteria;
$criteria->with =array('customer'=>array('select'=>'{{customer}}.*','joinType'=>'LEFT OUTER JOIN', ), );

and use relation function like

public function relations() { return array( 'customer' => array(self::BELONGS_TO, 'Customer', 'customer_id'), ); }

I think it solve your question

于 2013-04-18T14:09:03.833 回答
-1

在 yii 中连接表很容易。

您想在 $criteria 对象中加入代码

例如

$criteria=new CDbCriteria;

$criteria->with =array('customer'=>array('select'=>'{{customer}}.*','joinType'=>'LEFT OUTER JOIN', ), );

并使用关系函数

public function relations() {
    return array(
        'customer' => array(self::BELONGS_TO, 'Customer', 'customer_id'),
    );
}

我认为它解决了你的问题

于 2013-04-18T14:03:11.370 回答