Re: MySQL execution order...

From: Date: Fri, 23 Feb 2001 12:55:06 +0000
Subject: Re: MySQL execution order...
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-6907@lists.php.net to get a copy of this message
Sir, it would help to see the INSERT statement and the table definition. Bob Hall
I sent this message to the "general" list yesterday, and have yet to get an answer (except for that Spanish "Snow White" virus attempt from Peru). I'm trying to download info from a table as a tab-delimted text file. This part works fine. (By disabling the UPDATE statement in the code sample below, I can get the same data file sent time after time.) I need to keep the data in the table for future reference, and only want to download each new record once, so I added a DateTime field that gets updated after downloading. Then searching on that field gives me just the records that haven't been downloaded yet. The weird part is that it seems like the LAST MySQL command (UPDATE) gets executed before the FIRST one (SELECT), because the SELECT statement comes up with 0 rows. Here's some selected (modified) parts of the PHP code: ------------------------ First, I perform the SQL: SELECT * from db_table WHERE (DownloadedDateTime = '0000-00-00 00:00:00') Then, it parses and sends the info: while ($row = mysql_fetch_row($result)) {
    while (list($key, $val) = each($row)) {
       $val = ereg_replace("[\n\r\t]"," ",$val);
       $val = ereg_replace(" {2,}"," ",$val);
       echo $val . "\t";
    }
    //end of line
    echo "\r";
} Then I perform the SQL: UPDATE LOW_PRIORITY db_table SET DownloadedDateTime=CURRENT_TIMESTAMP WHERE (DownloadedDateTime = '0000-00-00 00:00:00') -------------------------- Any ideas why the rows are getting the DownloadedDateTime field updated before they get SELECTed? Thanks, Don Johnson don_mail2@mwtb.org -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net
Know thyself? Absurd direction!
Bubbles bear no introspection.     -Khushhal Khan Khatak


« previous php.db (#6907) next »