Re: Unbuffered Query

From: Date: Sat, 13 Jan 2007 06:04:37 +0000
Subject: Re: Unbuffered Query
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-247022@lists.php.net to get a copy of this message
Richard Lynch wrote:
I have this process that dumps out database records to static HTML pages. The basic algorithm goes like: //Set any un-parented item (a root in the thread) to be its own parent: update entry set original_id = entry_id where original_id is null in the following you are looking for dirty flagged rows, were they set to dirty before or after your previous statement?
//collect any "dirty" entries (changed in db, need to re-publish) $dirty = select entry_id from entry where dirty = 1 while (list($entry_id) = mysql_fetch_row($dirty)){ //find the whole thread: $followups = select entry_id, X, Y from entry where original_id = $dirty_id are you really meaning to use $dirty_id, or did you mean to use $entry_id??? $dirty_id doesn't exist as far as I can tell. unless it is something that was set before all this.
//there is an ORDER BY which is not relevant Personally, I would do some check right here to see if the result set has at least one row at this point and then issue a continue; if mysql_num_rows() returns 0. That way you won't get empty h? tags floating around.
//get some thread metadata from the first row's X field list($junk, $X) = mysql_fetch_row($followups); //$X is the same for all rows... echo "<h1>$X</h1>\n"; I would check your HTML output for empty <h1></h1> tags, this would tell you that it didn't find anything :(
Hope this helps Jim Lucas
//reset to row 0 mysql_data_seek($followups, 0); while (list($entry_id, $X, $Y) = mysql_fetch_row($followups)){
    echo "<p>$Y</p>\n";
} } So, how come *SOMETIMES*, seemingly at random, I get: Warning: mysql_data_seek(): Offset 0 is invalid for MySQL result index 116 (or the query data is unbuffered) in /www/acousticdemo.com/web/complaints/publish.cron on line 26 Line 26 is, obviously, the mysql_data_seek call above... I do not *THINK* there is any other process anywhere deleting rows from the table -- it should be an ever-growing table... So is the query data being unbuffered out from under me due to some my.cnf setting?... Or am I just plain wrong, and *something* is deleting from the entry table? I Googled for the error message, and found about a 26,000 web sites that are exhibiting this error, rather than the folks discussing this error. :-v The few I was able to weed out were obvious logic errors, which I don't think I have. I've read the mysql_unbuffered_query on php.net and think I understand it in respect to mysql_query et al. I guess I'm looking for reassurance that it's definitely my mistake somewhere in the mess I've made, and that I'm looking for a delete query, and it's not a subtle bug or feature I'm failing to understand. :-)


« previous php.general (#247022) next »