LEFT JOIN in ZF2 using TableGateway

前端 未结 7 1821
无人共我
无人共我 2021-01-03 23:01

I have a table:

*CREATE TABLE IF NOT EXISTS `blogs_settings` (
  `blog_id` int(11) NOT NULL AUTO_INCREMENT,
  `owner_id` int(11) NOT NULL,
  `title` varchar(         


        
7条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-03 23:14

    if you're using TableGateway, you can select join like this

    $sqlSelect = $this->tableGateway->getSql()->select();
    $sqlSelect->columns(array('column_name'));
    $sqlSelect->join('othertable', 'othertable.id = yourtable.id', array(), 'left');
    
    $resultSet = $this->tableGateway->selectWith($sqlSelect);
    return $resultSet;
    

提交回复
热议问题