php - CodeIgniter. Allowed memory size error and pagination
Get the solution ↓↓↓Solution:
Your codeigniter code is storing the entire list in array first. After that you are trying to build the screen. Perhaps you can start with a SQL join and use limit in that join to restrict the number of rows. Also, send your script page number for pagination.
<?php
$current = $_GET['page'];
$rowCount = $_GET['length'];
$sql = "select * from model m
inner join brand b
on m.vehicle_brand_id = b.id
limit ".($current - 1)*($rowCount).",".$rowCount;
$query = $this->db->query($sql);
$content['tableList'] = $query->result();
In this way, you will not pull entire data, which eventually causes memory exhaustion error.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: trying to access array offset on value of type bool in
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.