Welcome Guest, Not a member yet? Register   Sign In
Flexigrid CodeIgniter Implementation
#20

[eluser]Armorfist[/eluser]
Hi again,

The active record actually simplifies a lot! Again, great idea daBayrus Smile

Already implemented the active record, however in the COUNT query I did something different than you daBayrus.
In your approach, you get the last executed query, remove LIMIT and do a num_rows. This is fine for query's with small results, but for query's that return thousands of results executing the whole query just to count is not very good.
So here's my model:
Code:
public function get_countries()
    {
        //Select table name
        $table_name = "country";
        
        //Build contents query
        $this->db->select('id,iso,name,printable_name,iso3,numcode')->from($table_name);
        $this->CI->flexigrid->build_query();
        
        //Get contents
        $return['records'] = $this->db->get();
        
        //Build count query
        $this->db->select('count(id) as record_count')->from($table_name);
        $this->CI->flexigrid->build_query(FALSE);
        $record_count = $this->db->get();
        $row = $record_count->row();
        
        //Get Record Count
        $return['record_count'] = $row->record_count;
    
        //Return all
        return $return;
    }

And I had to add a little parameter to the build_query function so it can strip the LIMIT from the count query:

Code:
public function build_query($limit = TRUE)
    {
        if ($this->post_info['swhere'])
            $this->CI->db->where($this->post_info['swhere']);
    
        $this->CI->db->order_by($this->post_info['sortname'], $this->post_info['sortorder']);
        
        if ($limit)
            $this->CI->db->limit($this->post_info['rp'], $this->post_info['limitstart']);
    }

Tell me what you think Wink

Going to update the documentation and then upload this modification.


Messages In This Thread
Flexigrid CodeIgniter Implementation - by El Forum - 09-05-2008, 01:07 PM
Flexigrid CodeIgniter Implementation - by El Forum - 09-06-2008, 02:33 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-06-2008, 05:47 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-06-2008, 11:13 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-06-2008, 11:53 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-07-2008, 07:15 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-07-2008, 08:23 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-07-2008, 12:27 PM
Flexigrid CodeIgniter Implementation - by El Forum - 09-09-2008, 07:13 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-12-2008, 07:28 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-12-2008, 07:43 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-12-2008, 09:14 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-12-2008, 09:25 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-12-2008, 12:28 PM
Flexigrid CodeIgniter Implementation - by El Forum - 09-17-2008, 04:25 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-17-2008, 06:09 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-17-2008, 02:01 PM
Flexigrid CodeIgniter Implementation - by El Forum - 09-21-2008, 02:18 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-21-2008, 05:27 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-21-2008, 06:03 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-21-2008, 01:14 PM
Flexigrid CodeIgniter Implementation - by El Forum - 09-26-2008, 06:15 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-27-2008, 12:30 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-27-2008, 02:49 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-27-2008, 03:37 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-28-2008, 12:03 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-29-2008, 12:18 AM
Flexigrid CodeIgniter Implementation - by El Forum - 09-29-2008, 03:00 AM
Flexigrid CodeIgniter Implementation - by El Forum - 10-02-2008, 05:25 PM
Flexigrid CodeIgniter Implementation - by El Forum - 10-02-2008, 05:27 PM
Flexigrid CodeIgniter Implementation - by El Forum - 10-29-2008, 03:25 AM
Flexigrid CodeIgniter Implementation - by El Forum - 10-29-2008, 04:04 AM
Flexigrid CodeIgniter Implementation - by El Forum - 10-29-2008, 06:02 AM
Flexigrid CodeIgniter Implementation - by El Forum - 10-29-2008, 06:24 AM
Flexigrid CodeIgniter Implementation - by El Forum - 11-01-2008, 09:23 PM
Flexigrid CodeIgniter Implementation - by El Forum - 11-09-2008, 12:21 AM
Flexigrid CodeIgniter Implementation - by El Forum - 11-19-2008, 12:21 AM
Flexigrid CodeIgniter Implementation - by El Forum - 12-01-2008, 03:20 AM
Flexigrid CodeIgniter Implementation - by El Forum - 12-01-2008, 12:50 PM
Flexigrid CodeIgniter Implementation - by El Forum - 12-02-2008, 09:43 AM
Flexigrid CodeIgniter Implementation - by El Forum - 12-02-2008, 02:13 PM
Flexigrid CodeIgniter Implementation - by El Forum - 12-02-2008, 04:32 PM
Flexigrid CodeIgniter Implementation - by El Forum - 12-20-2008, 08:04 PM
Flexigrid CodeIgniter Implementation - by El Forum - 01-16-2009, 01:27 PM
Flexigrid CodeIgniter Implementation - by El Forum - 01-16-2009, 03:46 PM
Flexigrid CodeIgniter Implementation - by El Forum - 01-17-2009, 08:24 AM
Flexigrid CodeIgniter Implementation - by El Forum - 02-20-2009, 03:03 PM
Flexigrid CodeIgniter Implementation - by El Forum - 02-22-2009, 07:25 PM
Flexigrid CodeIgniter Implementation - by El Forum - 04-28-2009, 06:07 AM
Flexigrid CodeIgniter Implementation - by El Forum - 05-07-2009, 12:32 PM
Flexigrid CodeIgniter Implementation - by El Forum - 05-11-2009, 07:31 AM
Flexigrid CodeIgniter Implementation - by El Forum - 05-13-2009, 10:51 AM
Flexigrid CodeIgniter Implementation - by El Forum - 05-13-2009, 01:02 PM
Flexigrid CodeIgniter Implementation - by El Forum - 05-14-2009, 07:56 AM
Flexigrid CodeIgniter Implementation - by El Forum - 05-16-2009, 01:44 AM
Flexigrid CodeIgniter Implementation - by El Forum - 06-21-2009, 05:20 AM
Flexigrid CodeIgniter Implementation - by El Forum - 07-27-2009, 01:06 PM
Flexigrid CodeIgniter Implementation - by El Forum - 08-17-2009, 09:34 PM
Flexigrid CodeIgniter Implementation - by El Forum - 11-05-2009, 03:08 PM
Flexigrid CodeIgniter Implementation - by El Forum - 12-17-2009, 11:22 AM
Flexigrid CodeIgniter Implementation - by El Forum - 01-05-2010, 03:32 PM
Flexigrid CodeIgniter Implementation - by El Forum - 01-06-2010, 04:35 AM
Flexigrid CodeIgniter Implementation - by El Forum - 01-13-2010, 12:02 PM
Flexigrid CodeIgniter Implementation - by El Forum - 01-13-2010, 12:07 PM
Flexigrid CodeIgniter Implementation - by El Forum - 01-19-2010, 12:49 AM
Flexigrid CodeIgniter Implementation - by El Forum - 01-28-2010, 02:13 PM
Flexigrid CodeIgniter Implementation - by El Forum - 01-29-2010, 01:02 PM
Flexigrid CodeIgniter Implementation - by El Forum - 04-12-2010, 10:04 AM
Flexigrid CodeIgniter Implementation - by El Forum - 04-12-2010, 03:59 PM
Flexigrid CodeIgniter Implementation - by El Forum - 04-14-2010, 08:45 PM
Flexigrid CodeIgniter Implementation - by El Forum - 04-27-2010, 07:58 PM
Flexigrid CodeIgniter Implementation - by El Forum - 04-29-2010, 03:56 AM
Flexigrid CodeIgniter Implementation - by El Forum - 04-29-2010, 04:25 AM
Flexigrid CodeIgniter Implementation - by El Forum - 04-29-2010, 04:41 AM
Flexigrid CodeIgniter Implementation - by El Forum - 04-29-2010, 05:44 AM
Flexigrid CodeIgniter Implementation - by El Forum - 05-09-2010, 01:12 PM
Flexigrid CodeIgniter Implementation - by El Forum - 05-09-2010, 07:09 PM
Flexigrid CodeIgniter Implementation - by El Forum - 05-09-2010, 07:21 PM
Flexigrid CodeIgniter Implementation - by El Forum - 05-09-2010, 08:14 PM
Flexigrid CodeIgniter Implementation - by El Forum - 05-09-2010, 08:20 PM
Flexigrid CodeIgniter Implementation - by El Forum - 05-09-2010, 08:44 PM
Flexigrid CodeIgniter Implementation - by El Forum - 05-09-2010, 09:07 PM
Flexigrid CodeIgniter Implementation - by El Forum - 05-09-2010, 09:11 PM
Flexigrid CodeIgniter Implementation - by El Forum - 05-09-2010, 09:59 PM
Flexigrid CodeIgniter Implementation - by El Forum - 05-09-2010, 10:25 PM
Flexigrid CodeIgniter Implementation - by El Forum - 05-10-2010, 12:03 AM
Flexigrid CodeIgniter Implementation - by El Forum - 05-10-2010, 12:05 AM
Flexigrid CodeIgniter Implementation - by El Forum - 05-10-2010, 03:22 AM
Flexigrid CodeIgniter Implementation - by El Forum - 05-10-2010, 08:23 PM
Flexigrid CodeIgniter Implementation - by El Forum - 05-17-2010, 01:25 AM
Flexigrid CodeIgniter Implementation - by El Forum - 05-17-2010, 01:26 AM
Flexigrid CodeIgniter Implementation - by El Forum - 05-17-2010, 02:01 AM
Flexigrid CodeIgniter Implementation - by El Forum - 05-17-2010, 09:13 PM
Flexigrid CodeIgniter Implementation - by El Forum - 05-17-2010, 09:51 PM
Flexigrid CodeIgniter Implementation - by El Forum - 06-18-2010, 12:15 AM
Flexigrid CodeIgniter Implementation - by El Forum - 06-18-2010, 07:41 AM
Flexigrid CodeIgniter Implementation - by El Forum - 06-19-2010, 03:43 AM
Flexigrid CodeIgniter Implementation - by El Forum - 07-02-2010, 10:35 AM
Flexigrid CodeIgniter Implementation - by El Forum - 07-06-2010, 05:53 AM
Flexigrid CodeIgniter Implementation - by El Forum - 07-07-2010, 06:46 AM
Flexigrid CodeIgniter Implementation - by El Forum - 07-07-2010, 08:04 AM
Flexigrid CodeIgniter Implementation - by El Forum - 07-07-2010, 12:10 PM
Flexigrid CodeIgniter Implementation - by El Forum - 07-07-2010, 12:53 PM
Flexigrid CodeIgniter Implementation - by El Forum - 07-10-2010, 03:08 PM
Flexigrid CodeIgniter Implementation - by El Forum - 07-18-2010, 01:49 PM
Flexigrid CodeIgniter Implementation - by El Forum - 07-26-2010, 10:01 AM
Flexigrid CodeIgniter Implementation - by El Forum - 07-28-2010, 12:17 PM
Flexigrid CodeIgniter Implementation - by El Forum - 09-22-2010, 12:35 PM
Flexigrid CodeIgniter Implementation - by El Forum - 11-06-2010, 09:19 PM
Flexigrid CodeIgniter Implementation - by El Forum - 11-07-2010, 10:31 PM
Flexigrid CodeIgniter Implementation - by El Forum - 11-07-2010, 11:05 PM
Flexigrid CodeIgniter Implementation - by El Forum - 11-08-2010, 02:36 AM
Flexigrid CodeIgniter Implementation - by El Forum - 11-14-2010, 03:32 PM
Flexigrid CodeIgniter Implementation - by El Forum - 11-15-2010, 05:01 PM
Flexigrid CodeIgniter Implementation - by El Forum - 01-12-2011, 01:10 AM
Flexigrid CodeIgniter Implementation - by El Forum - 01-23-2011, 03:10 AM
Flexigrid CodeIgniter Implementation - by El Forum - 02-08-2011, 04:13 AM
Flexigrid CodeIgniter Implementation - by El Forum - 02-08-2011, 04:53 AM
Flexigrid CodeIgniter Implementation - by El Forum - 02-16-2011, 01:19 AM
Flexigrid CodeIgniter Implementation - by El Forum - 02-16-2011, 01:54 AM
Flexigrid CodeIgniter Implementation - by El Forum - 02-17-2011, 10:57 AM
Flexigrid CodeIgniter Implementation - by El Forum - 02-17-2011, 03:26 PM
Flexigrid CodeIgniter Implementation - by El Forum - 02-19-2011, 03:11 AM
Flexigrid CodeIgniter Implementation - by El Forum - 04-04-2011, 10:50 PM
Flexigrid CodeIgniter Implementation - by El Forum - 04-27-2011, 08:24 PM
Flexigrid CodeIgniter Implementation - by El Forum - 05-04-2011, 01:05 AM
Flexigrid CodeIgniter Implementation - by El Forum - 05-04-2011, 01:51 AM
Flexigrid CodeIgniter Implementation - by El Forum - 04-04-2012, 10:50 AM
Flexigrid CodeIgniter Implementation - by El Forum - 04-20-2012, 07:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB