Select last N rows from MySQL - codeigniter
06:43 27 Sep 2015

I'm using codeigniter;

I would like to get last N rows from my table.

In my query I want to get last 200 rows:

         $this->m_general->select('count(*)');
         $this->m_general->from('pm');
         $result_count_query = $this->m_general->get();
         $count_query = $result_count_query->num_rows();



$data['all']     = $this->m_general->get('pm', array( 'admin_delete'=>0 ) , $count_query-200,$count_query, array('admin_seen'=>'asc' , 'id'=>'desc') );

but it returns nothing.

where is my wrong ?

updated

below query not worked fine and it returns all records :

$data['all']     = $this->m_general->get('pm', array( 'admin_delete'=>0 ) ,200, array('admin_seen'=>'asc' , 'id'=>'desc') );
php codeigniter sql-order-by limit query-builder