我有两个表,分别是发货地址和账单地址。我对这些表使用联接。但不幸的是,两个表的字段名称是相同的。我想回显这两个数据。
$this->db->select('a.*,b.*,c.*');
$this->db->from('pr_order_products as a');
$this->db->join('cust_bill_address as b','a.user_id = b.cust_id','inner');
$this->db->join('cust_ship_address as c','a.user_id = c.cust_id','inner');
$this->db->where($cond);
$query = $this->db->get();
echo $this->db->last_query(); exit;
return $query;
如果我获取结果并且echo $order->cust_id;
意味着它只从billing_address表中获取。有什么办法吗?
在select语句中显式设置数据字段:
$this->db->select('
a.cust_id as a_cust_id,
b.cust_id as b_cust_id,
c.cust_id as c_cust_id,
etc...');