私はこのようなモデルの機能を持っている:文が常にクエリの実行中に実行された場合CodeIgniterのActive RecordのIF文
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();
}
}
最初の文も実行されている場合、私は2番目をしたいです。
が列
tb_lqs083hdr.product_type = 'Finished Product Coconut Cream'
は、最初の文が実行される場合場合:は、私は、クエリの条件を持っています。
elseコラム
tb_lqs083hdr.product_type = 'Finished Product'
の場合は、2番目のif文が実行されます。
どちらの条件も互いに類似しているようですが、私の表では両方の条件に異なる値があります。
私はまだクエリを評価しています。だから、どんな助けもありがとう。
ありがとうございました。
大丈夫です、私はあなたの提案を使用しようとします、これはおそらく – metaphor
何かのように動作することを願っていますか?以下の回答を参照してください。 – PaulD