-1
//model
public function getAllPurchaseItems($purchase_id)
{
$this->db->select('purchase_items.purchase_id,
purchase_items.transfer_id, purchase_items.product_id,
purchase_items.product_code, purchase_items.product_name,
purchase_items.option_id, purchase_items.net_unit_cost,
purchase_items.quantity, purchase_items.warehouse_id,
purchase_items.item_tax, purchase_items.tax, purchase_items.discount,
purchase_items.item_discount, purchase_items.expiry,
purchase_items.subtotal, purchase_items.quantity_balance,
purchase_items.date, purchase_items.status, categories.name');
$this->db->from('purchase_items');
$this->db->join(products, 'products.id = purchase_items.product_id');
$this->db->join(categories, 'categories.id = products.category_id');
$this->db->order_by('purchase_items.id', 'asc');
$q = $this->db->where(array('purchase_items.purchase_id' =>
$purchase_id));
if ($q->num_rows() > 0) {
foreach (($q->result()) as $row) {
$data[] = $row;
}
return $data;
}
return FALSE;
}
// controller
$this->data['rows'] = $this->purchases_model->getAllPurchaseItems($purchase_id);
正確地格式化代碼1 – Bugfixer
只是代碼?你錯過了'」「'你的連接查詢。使用「產品」和「類別」。加入查詢不起作用或者你犯了錯誤? –