找到了这么多的答案,但仍然不起作用,这是我的两个连接查询

$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();

从事务表中获取除“餐厅”和“用户积分”表以外的所有记录
连接有问题吗?

最佳答案

试试这个

$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-如何使用“where_in”子句查询“左联接”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46272760/

10-10 14:30