Sir,
I am facing a problem and it is shown below: I want to perform where opertion on the output of $this->db->select('*')->from('table'); only when cond1 satisfies
$result = $this->db->select('*')->from('table');
if(cond1)
{
I want to perform $result->where(); operation
}
Is it possible and i so what is the exact syntax to do it
try something like this:
$this->db->select('*');
$this->db->from('table');
if ($cond1)
$this->db->where(...)
$query = $this->db->get();
$con1
is should be a variable and it should has a value or Null. $con1
like a Boolean.1 or 0 .if 1(true) happening it'll execute the if block if not it'll execute the else block.
Looks like you want to run two different queries. Assuming that $cond1
is not dependent upon $result
(in which case all bets are off), you can do something like
if(cond1)
$result = $this->db->select('*')->from('table')->where(...);
else
$result = $this->db->select('*')->from('table');