Model::join
Set Join Parameter
Description
public self Model::join( string $table, [ string $type = 'INNER', string $on = null, array $data = [] ] )
Arguments
Name | Data type | Default | Remarks |
---|---|---|---|
$table | string | Target table | |
$type | string | 'INNER' | Join mode |
$on | string | NULL | On query |
$data | array | [] | On query parameters |
Example
Controller
$model = new Model(false, array(
'table' => 'cms_news',
'id' => 'news_id',
'visible' => 'visible',
));
$model->join('cms_user', 'LEFT', 'cms_news.user_id = cms_user.user_id');
// SELECT *
// FROM cms_news
// LEFT JOIN cms_user
// ON cms_news.user_id = cms_user.user_id
$records = $model->find();