按供应商选择的编码器



我正试图通过供应商选择产品,但代码似乎从数据库返回每个产品,我无法找出原因,但它必须是我缺少的东西,因为我不是编码专家,我非常感谢您对此的输入,谢谢

    -----Controller page-----

    {
    $this->data['store_products'] = $this->productss->get_products_by_supplier_id();
    $this->data['store_suppliers'] = $this->productss->get_join_suppliers();
    $this->data['tax_settings'] = $this->productss->get_all_taxs();
    $this->data['store_taxs'] = $this->productss->get_join_taxs();
           
    $this->load->view('products/by_supplier', $this->data);
    }


    ----------- Model page-----


    public function get_products_by_supplier_id()
     {
            $this->db->select('*');
    $this->db->from('store_products');
    $this->db->join('store_suppliers', 'store_products.supplierid = store_suppliers.supplierid','left');
    $this->db->join('tax_settings', 'store_products.taxid = tax_settings.taxid','left');
    $this->db->where('store_suppliers.supplierid',$supplierid);
        
        
            $query =  $this->db->get();
    if ($query->num_rows() > 0)
    {
    return $query->result_array();
    }
    else
    {
    return array();
    }
        } 

是否尝试在连接查询中删除参数'left' ?

改变这些行。比较的顺序很重要。我更改它并运行查询。

 $this->db->join('store_suppliers', ' store_suppliers.supplierid = store_products.supplierid');
 $this->db->join('tax_settings', 'tax_settings.taxid =store_products.taxid');

$supplierid

$this->db->where('store_suppliers.supplierid',$supplierid);

在这里传递供应商id

get_products_by_supplier_id() to
get_products_by_supplier_id($supplierid)

排序后,索引页上的url没有正确传递参数。

使用-

移除64进制编码解决问题

最新更新