我在从 codeigniter Controller 中获取此数据时遇到问题。
$q = $this->db->get('offers_orders');
$this->db->select('total');
$this->db->where('order_number', $orderid);
$orderdata = $q->result_array();
$orderamount = $orderdata[0]['total'];
你发现这段代码有什么问题吗?
最佳答案
是的,尝试一下:
$this->db->select('count(*) as total', false);
$this->db->where('order_number', $orderid);
$q = $this->db->get('offers_orders');
或者,
$q = $this->db->select('count(*) as total', false)->where('order_number', $orderid)->get('offers_orders');
关于php - 通过Codeigniter从MySQL表中获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17569187/