0

様、

私は問題に直面しており、それを以下に示します: $this->db->select('*')->from('table'); の出力に対して where 操作を実行したい cond1 が満たされる場合のみ

 $result = $this->db->select('*')->from('table');
 if(cond1)
 {
  I want to perform $result->where(); operation
 }

それは可能ですか、それを行うための正確な構文は何ですか

4

3 に答える 3

0

2 つの異なるクエリを実行したいようです。$cond1それが依存していないと仮定すると$result(この場合、すべての賭けはオフになります)、次のようなことができます。

if(cond1)
    $result = $this->db->select('*')->from('table')->where(...);
else
    $result = $this->db->select('*')->from('table');
于 2013-06-12T19:56:14.980 に答える