【发布时间】:2016-08-08 04:40:00
【问题描述】:
我有一个这样的模型函数:
function get_dtsample083($dt_date_production,$dt_filler) {
$this->db1->select('detail_id_sample as detail_id083, detail_id as detail_id_mic, detail_id_sample087_096, headerid_sample, sampling_time, sample_code, product_id, temp, filler, ph, csp_la_35, csp_la_55, tab, operator, remark, rough_mic');
$this->db1->from('tb_lqs083dtl');
$this->db1->join('tb_lqs083hdr', 'tb_lqs083hdr.headerid = tb_lqs083dtl.headerid');
$this->db1->where('tb_lqs083hdr.date_production',$dt_date_production);
$this->db1->where('tb_lqs083hdr.filler',$dt_filler);
$try1 = 'Finished Product Coconut Cream';
$try2 = 'Finished Product';
if($this->db1->where('tb_lqs083hdr.product_type',$try1)) {
$this->db1->where('tb_lqs083hdr.product_type',$try1);
$this->db1->where('tb_lqs083dtl.stdtl','1');
$this->db1->order_by("tb_lqs083dtl.headerid_sample", "asc");
$this->db1->order_by("tb_lqs083dtl.detail_id_sample087_096", "asc");
$this->db1->order_by("tb_lqs083hdr.temp", "asc");
} elseif($this->db1->where('tb_lqs083hdr.product_type !=',$try1)) {
$this->db1->where('tb_lqs083hdr.product_type',$try2);
$this->db1->where('tb_lqs083hdr.product_name','Coconut Cream');
$this->db1->where('tb_lqs083dtl.stdtl','1');
$this->db1->order_by("tb_lqs083dtl.headerid_sample", "asc");
$this->db1->order_by("tb_lqs083dtl.detail_id_sample087_096", "asc");
$this->db1->order_by("tb_lqs083hdr.temp", "asc");
} else {}
$query = $this->db1->get();
echo $this->db1->last_query();
if ($query->num_rows() > 0) {
return $query->result();
}
}
第一个 if 语句总是在查询执行中执行,我希望第二个 if 语句也正在执行。
我有一个查询条件:
如果列
tb_lqs083hdr.product_type = 'Finished Product Coconut Cream',则将执行第一个if语句。else if 列
tb_lqs083hdr.product_type = 'Finished Product'然后执行第二个 if 语句。
这两个条件似乎彼此相似,但在我的表格中,两个条件的值不同。
我仍在评估我的查询。因此,我们将不胜感激。
谢谢。
【问题讨论】:
标签: php database postgresql codeigniter