• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Large DB recordset - returns num_rows, but no row data

#1
[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

#2
[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

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

#4
[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.

#5
[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.

#6
[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!?

#7
[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.....

#8
[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.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.