Reputation: 163
I am using CodeIgniter and active record. I am selecting my data over WHERE with array. Any like this. But how can I insert >
and <
as the comparison operator? It is possible?
$whereQuery['service.service_end_date'] = $start;
Upvotes: 3
Views: 12809
Reputation: 3480
This might be what you want:
Associative array method:
$array = array('name' => $name, 'title' => $title, 'status' => $status);
$this->db->where($array);
// Produces: WHERE name = 'Joe' AND title = 'boss' AND status = 'active'
You can include your own operators using this method as well:
$array = array('name !=' => $name, 'id <' => $id, 'date >' => $date);
$this->db->where($array);
Source:
http://ellislab.com/codeigniter/user-guide/database/active_record.html
Upvotes: 3
Reputation: 2203
From Codeigniter page :
You can include an operator in the first parameter in order to control the comparison:
$this->db->where('name !=', $name);
$this->db->where('id <', $id);
// Produces: WHERE name != 'Joe' AND id < 45
Upvotes: 0
Reputation: 8840
http://ellislab.com/codeigniter/user-guide/database/active_record.html
$whereQuery['service.service_end_date >'] = $start;
$whereQuery['service.service_end_date <'] = $start;
You can pass > < <>
in CI where function
$this->db->where('field_name <', "Condition_value");
Upvotes: 1