[eluser]Ornis[/eluser]
I created a generic model-class including the following SELECT method:
function mySelect( $table = '',
$arr_fields = array(),
$where = '',
$group_by = '',
$having = '',
$order_by = '',
$limit = ''
) {
//=== mandatory query elements
$this->db->select($arr_fields);
$this->db->from($table);
/*
* Process optional query statements
*/
//=== allowed query-options defined in an array
$arr_sqloptions = array('where' => $where,
'group_by' => $group_by,
'having' => $having,
'order_by' => $order_by,
'limit' => $limit);
//=== go through all allowed options
foreach($arr_sqloptions AS $key => $value) {
//=== is this option passed?
if(strlen($value) > 0) {
//=== add query-option
$this->db->$key ( $value );
}
}
//=== execute query and return result in an array
return $this->db->get()->result_array();
}
Everything works fine except when I pass limit with an offset i.e. '10,300'. Then the factory above does not produce the LIMIT(10,300) statement. It's just ignoring the LIMIT-options.
What's wrong here?
Thanks Martin