Apakah Anda menjalankan kueri di dalam semacam lingkaran?
Setuju dengan jawaban pagination, gunakan batas dan offset. Jika Anda menjalankan 10 per halaman, itu berarti 700 kueri. Saya akan menggunakan lib pagination codeigniter sebagai berikut.
$route['controller/(:num)'] = 'controller/index/$1';
-
public function index($offset=0)
{
//set a limit of 10 per result
$limit = 10;
//query the database
$q = "SELECT * FROM {table_name} LIMIT={limit} OFFSET={offset} ORDER BY {date} desc";
//count the results
$count = count({query results});
//setup pagination config
$config = array(
'base_url' => site_url('controller/'),
'total_rows' => $count,
'per_page' => $limit,
'uri_segment' => 2
);
//init the pagigination
$this->pagination->initialize($config);
//load the view and pagination data
$this->load->view('link_to_template', array(
'pagination' => $this->pagination->create_links(),
'results' => {query results}
));
}