0

我有疑问:

$sql = new Sql($this->tableGateway->getAdapter());
$select = $sql->select();

$select->from('table_1')
    ->join('table_2', 'table_2_se_id = table_2.se_id 
                       and table_2_table_3_id = table_2.table_3_id',
                      '*', 'LEFT')
    ->join('table_3', 'table_2_table_3_id=table_3.id', '*', 'LEFT')
    ->join('table_4', 'table_4_id=table_4.id', '*', 'LEFT');

如何从 table_4 中仅获取一列(例如“名称”)?

4

1 回答 1

2

第三个参数join()是您指定列的位置,此时您正在选择 all *。该参数可以是表示单个列的字符串,也可以是列数组,因此以下应该可以工作

->join('table_4', 'table_4_id=table_4.id', 'name', 'LEFT');
于 2013-03-10T09:47:32.233 回答