【问题标题】:Select join two tables with Zend DB [closed]选择使用 Zend DB 连接两个表 [关闭]
【发布时间】:2013-03-05 01:19:37
【问题描述】:

我有 2 个表:users 和 user_profile:

users: (user_id, email, password, created_date)

user_profile: (user_id, first_name, last_name, address, birthday)

使用 Zend DB 选择我想加入这两个表(像这样)

INNER JOIN `users` ON `users`.`user_id`=`user_profile`.`user_id`

现在的问题是我不知道如何使用 Zend_Db 通过 Select join 来实现这一点。 请帮帮我。非常感谢!!!

【问题讨论】:

    标签: php database zend-framework select join


    【解决方案1】:
    $select = $this->select()
                    ->from('users')
                    ->joinLeft(array('userprofile'=>'user_profile'),'users.user_id = userprofile.user_id')
                    ->where('users.user_id = ?', 1);   
    

    这是在 zend 中连接两个表的方法。查看 ZF 手册以了解 zend join zend.db.select.building.join 的高级用法

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-17
      • 2019-03-23
      相关资源
      最近更新 更多