1
過濾器我要創建過濾器創建具有多輸入笨
這裏是我的模式
<?php
function show($branch,$department,$employee,$status,$from,$to,$category)
{
$this->db->select('a.*,b.name,c.cityname');
$this->db->from('expreport a');
$this->db->join('expuser b','a.createdby=b.unique_id');
$this->db->join('expcity c','a.cityid=c.citycode');
if($branch != "" || $status !="" || $from !="" || $to !="" || $department !="" || $employee !="")
{
$this->db->select('d.employeename,e.branchname,f.deptname');
$this->db->from('expemployee d');
$this->db->join('expbranch e','d.branchid=e.branchcode');
$this->db->join('expdepartment f','d.deptid=f.deptcode');
$this->db->like('branchid', $branch);
$this->db->or_like('deptid', $department);
$this->db->or_like('employeeid', $employee);
$this->db->where('status', $status);
$this->db->where('fromdate <=',$from);
$this->db->where('todate >=',$to);
}
if($category !="")
{
$this->db->select('g.category');
$this->db->from('expcategory g');
$this->db->like('catcode', $category);
}
$this->db->group_by('reportcode');
$result = $this->db->get();
echo $this->db->last_query();
return $result->result();
}
?>
我有鑑於7倍的投入,我想分開$分公司,$狀態,$等,所以查詢可以從1變量執行,所以我不必輸入所有變量,因爲當我只是填寫1輸入,查詢不執行
All Answers will be appreciated ,謝謝:)
僅使用單變量$數據在函數參數時傳遞給從控制器使用$數據[「分支」]起作用。 –
你能舉一些例子嗎? @AmitChauhan –
所以我應該使模型中的7個功能?一旦函數包含每個輸入的查詢?? –