3
votes

I am using codeigniter and active record. I am selecting my data over WHERE with array. Any like this. But how can I insert tags '>' and '<'? It is possible?

$whereQuery['service.service_end_date'] = $start;

Thank you for replies.

3

3 Answers

3
votes

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

1
votes

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"); 
0
votes

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