CodeIgniter Forums
Large DB recordset - returns num_rows, but no row data - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Large DB recordset - returns num_rows, but no row data (/showthread.php?tid=14044)



Large DB recordset - returns num_rows, but no row data - El Forum - 12-16-2008

[eluser]bwuk[/eluser]
Hi,

I have a DB query that returns over 50000 results from the DB.

If we assume that my function and query looks like

Code:
function get_all_rec()
{

$this->db->select('*');
$this->db->from('my_table');

$qUsers = $this->db->get();

return $qUsers
}

and then in another method in the class, I have:

Code:
$qUsers = $this->get_all_rec();

I can then output:

Code:
echo 'num_rows(): '.$qUsers->num_rows().'<br />';

but when I try and get:

Code:
echo 'first row, user id: '.$qUsers->row(0)->user_id.'<br />';

codeigniter/php doesn't return anything. The whole script terminates and I don't know why.

Has anyone else had this issue with CI?


Thanks


bwuk


Large DB recordset - returns num_rows, but no row data - El Forum - 12-16-2008

[eluser]bwuk[/eluser]
I should also add that it works on my local WAMP environment, but when put into a CentOS, Apache, Mysql, PHP env, it fails


Large DB recordset - returns num_rows, but no row data - El Forum - 12-16-2008

[eluser]xwero[/eluser]
check the log file.


Large DB recordset - returns num_rows, but no row data - El Forum - 12-16-2008

[eluser]phpserver[/eluser]
You will need to have your results as an array and then output userid | first row in a table.That will work.You will find the topic about generating results very useful,take a look.


Large DB recordset - returns num_rows, but no row data - El Forum - 12-16-2008

[eluser]bwuk[/eluser]
Hi,

Unfortunately, this is now on a live site, so I can't check the CI logs (if that's what you meant), as it slows the site down far too much.

I've tried changing the return type to result_array(), but still it won't return the user data.


Large DB recordset - returns num_rows, but no row data - El Forum - 12-16-2008

[eluser]davidbehler[/eluser]
I can't really help you with this but I am kinda curious why you want to output 50000 rows of data!?


Large DB recordset - returns num_rows, but no row data - El Forum - 12-16-2008

[eluser]bwuk[/eluser]
Hi,

I'm not wanting to output the data....instead I want to run some code against each other. Think of it as a cron against all users.

The only other thing I can think of is to limit it to 1000 each time or something.....


Large DB recordset - returns num_rows, but no row data - El Forum - 12-16-2008

[eluser]davidbehler[/eluser]
I think running 50 querys that return 1000 rows each might be faster than having one huge query with 50000 rows. But you might have to benchmark to find out.