views:

206

answers:

3

I'm trying this:

function send_sms() {
 $liveQuery = $this->db->get('liveList');
 $counter = 0;

 foreach($liveQuery->result() as $row):
  $counter = $counter+1;
  echo("Not hatin', just iteratin'. Message " . $counter);
 endforeach;
}

When liveList has 8000 records it runs just fine, but when I try with 9000 rows it generates a download of a blank, 0 KB, document. Anyone know why this happens?

A: 

I am not familiar with codeigniter, but do you have php error reporting on? There could be an error being thrown that's hidden.

CodeIgniter by default uses E_ALL, most people don't change this.
Phil Sturgeon
Ok, but if the problem is solved by your post then it should still be throwing an error code that it has gone over its memory. Since it isn't I can only assume that he shut error reporting off.
Not entirely. If you read down you will see there is a way of using a private method which is much better at handling large datasets.It is clearly timing out or running out of memory right now, so using the lighter method means this should not happen.
Phil Sturgeon
Phil, yes I am not saying that you didn't provide the fix for his problem, but that if his screen is blank, error reporting must be off.
Gotcha :-) This may well fix 9000 but he wont know if it breaks at 10000 without error reporting sorted lol
Phil Sturgeon
A: 

This post should help you:

http://codeigniter.com/forums/viewthread/129194/

Phil Sturgeon
Read down a bit, to this post:http://codeigniter.com/forums/viewreply/637930/
Phil Sturgeon
OK, I've read it, but i dont understand the "where('field1', 1)" part of this... $results = $this->db->select('field1, field2')->from('table')->where('field1', 1)->get();What does that part do?
Frode
He is using method chaining to build his ActiveRecord query. It's a PHP5 only syntax that reads better and takes up less space. $query = $this->db->select('field1, field2')->from('table')->where('field1', 1)->get();is the same as $this->db->select('field1, field2');$this->db->from('table');$this->db->where('field1', 1);$query = $this->db->get();
Phil Sturgeon
Thanks! Your answer, and a bit of reading the documentation, and before I knew it, Bob was my uncle.
Frode
A: 

Blank pages are normally a symptom of time-outs or crashed scripts. You might be able to find the exact reason in the server logs. Make sure you have the log_errors directive enabled in your PHP installation. Also, have a look at the web server logs.

Álvaro G. Vicario