gpt4 book ai didi

php - codeigniter - 如何使用 'left join' 子句查询 'where_in'

转载 作者:行者123 更新时间:2023-11-28 23:09:59 26 4
gpt4 key购买 nike

找到了很多答案,但仍然没有用,这是我的两个连接的查询

$query = $this->db->select('transaction.*,restaurant.logo_url,restaurant.cover_image_url,restaurant.slug,restaurant.delivery_time,user_points.point AS earned_points')
->from('transaction')
->join('restaurant', 'transaction.restaurant_id = restaurant.id', 'left')
->join('user_points', 'transaction.order_id = user_points.transaction_order_id', 'left')
->where_in('order_id', $order_id)
->get();
return ($query->num_rows() < 1) ? null : $query->result();

从事务表中获取除'restaurant'和'user_points'表之外的所有记录

连接有什么问题吗?

最佳答案

试试这个

$query = $this->db->select('transaction.*,restaurant.logo_url,restaurant.cover_image_url,restaurant.slug,restaurant.delivery_time,user_points.point AS earned_points',false)
->from('transaction')
->join('restaurant', 'transaction.restaurant_id = restaurant.id', 'left')
->join('user_points', 'transaction.order_id = user_points.transaction_order_id', 'left')
->where_in('order_id', $order_id)
->get();
return $query->result();

关于php - codeigniter - 如何使用 'left join' 子句查询 'where_in',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46272760/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com