codeigniter activerecord连接和表名别名问题

7hiiyaii  于 2021-06-25  发布在  Mysql
关注(0)|答案(0)|浏览(355)

我需要一个特定的codeigniter3.1.6活动记录查询,不断返回错误的帮助。
代码本身是:

$this->db->select('ms_payments.id, ms_payments.user_id, ms_payments.memberships_user_id, ms_payments.staff_id, ms_payments.rate_amount, ms_payments.tax, ms_payments.coupon, ms_payments.total, ms_payments.currency, ms_payments.pp, ms_payments.date,
u1.first_name AS user_name, u1.last_name AS user_last_name, u2.first_name AS staff_name, u2.last_name AS staff_last_name, 
ms_gateways.displayname AS pp, ms_memberships_users.id, ms_memberships.title AS membership')
      ->from('ms_payments')

      ->join('auth_users as u1', 'u1.id = ms_payments.user_id') 
      ->join('auth_users as u2', 'u2.id = ms_payments.staff_id') 

      ->join($this->gTable, 'ms_gateways.id = ms_payments.pp') 
      ->join($this->muTable, 'ms_memberships_users.id = ms_payments.memberships_user_id')
      ->join($this->mTable, 'ms_memberships.id = ms_memberships_users.membership_id')

      ->where('ms_payments.box_id =', $this->box_id);

$result = $this->db->get()->result();

这个问题与前两个连接有关,我怀疑是因为表名有别名。
$this->db->get\u compiled\u select()查询生成的sql查询非常有效:

SELECT `ms_payments`.`id`, `ms_payments`.`user_id`, `ms_payments`.`memberships_user_id`, `ms_payments`.`staff_id`, `ms_payments`.`rate_amount`, `ms_payments`.`tax`, `ms_payments`.`coupon`, `ms_payments`.`total`, `ms_payments`.`currency`, `ms_payments`.`pp`, `ms_payments`.`date`, 
`u1`.`first_name` AS `user_name`, `u1`.`last_name` AS `user_last_name`, `u2`.`first_name` AS `staff_name`, `u2`.`last_name` AS `staff_last_name`, `ms_gateways`.`displayname` AS `pp`, 
`ms_memberships_users`.`id`, `ms_memberships`.`title` AS `membership`

FROM `ms_payments`

JOIN `auth_users` as `u1` ON `u1`.`id` = `ms_payments`.`user_id`
JOIN `auth_users` as `u2` ON `u2`.`id` = `ms_payments`.`staff_id`

JOIN `ms_gateways` ON `ms_gateways`.`id` = `ms_payments`.`pp`
JOIN `ms_memberships_users` ON `ms_memberships_users`.`id` = `ms_payments`.`memberships_user_id`
JOIN `ms_memberships` ON `ms_memberships`.`id` = `ms_memberships_users`.`membership_id`

WHERE `ms_payments`.`box_id` = '1'

但我还是发现了这个codeigniter错误,为什么?
blockquote遇到未捕获的异常
blockquote类型:错误
blockquote消息:对布尔函数的成员函数result()的调用

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题