[eluser]pendalpusher[/eluser]
I was having some difficulty when doing complex querys. I also had problems with pagination because we are using postgres and not mysql. so the LIMIT 0,10 was not working properly. (I need to use LIMIT 10 OFFSET 0)
I just wanted to add to the list here and document what I changed in case anyone else runs across the same issues.
basically I am using the build_querys function in flexigrid.php library file.
I added this code around line 195
Code:
public function build_querys_complicated($querys)
{
$return['main_query'] = $querys['main_query'].' ORDER BY '.$this->post_info['sortname'].' '.$this->post_info['sortorder'].' LIMIT '.$this->post_info['rp'].' OFFSET '.$this->post_info['limitstart'];
$return['count_query'] = $querys['count_query'];
return $return;
}
then in my ajax_model.php file I have querys that look something like this.
Code:
$sql = "SELECT * FROM quote_log WHERE
active = '1'
AND
(customer LIKE '%".$string."%'
OR quote_title LIKE '%".$string."%'
OR estimator LIKE '%".$string."%'
OR salesman LIKE '%".$string."%')";
$querys['main_query'] = $sql;
//then to cheat a bit I am just swapping the * with count(id) to get the row counts.
$querys['count_query'] = str_replace("*","count(id)",$sql);
$build_querys = $this->CI->flexigrid->build_querys_complicated($querys);
$return['records'] = $this->db->query($build_querys['main_query']);
$record_count = $this->db->query($build_querys['count_query']);
//etc..etc...etc..
Anyway .. hope this helps someone someday.
These mods allowed me to run more complex querys and still maintain sorting and pagination.
Cheers,
C