LEFT JOIN in ZF2 using TableGateway

前端 未结 7 1797
无人共我
无人共我 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:15

    In your class inherited from AbstractTableGateway u can use Select with Closure like this:

    use Zend\Db\Sql\Select;
    ...
    public function getAllBlockSettings()
    {
        $resultSet = $this->select(function(Select $select) {
            $select->join('users', 'blogs_settings.owner_id = users.user_id', array('username'));
        });
    
        return $resultSet;
    }
    

提交回复
热议问题