Re: MySQL execution order?
| From: | Don Johnson | Date: | Fri, 23 Feb 2001 15:57:18 +0000 |
| Subject: | Re: MySQL execution order? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-41328@lists.php.net to get a copy of this message | ||
Yup, the data's correct. The new records all have the DownloadedDateTime as
'0000-00-00 00:00:00'
As an attempted fix, I even entered a pause between the two MySQL queries,
and made the UPDATE low_priority to make sure it wasn't jumping the gun.
No luck yet.
Don
in article 003d01c09d20$a16db610$8300000a@internal.graphictype.com,
"..s.c.o.t.t.. [gts]" at scott@graphictype.com wrote on 2/22/01 7:11 PM:
> mysql executes the queries in the order it recieves
> them, (so if your program's logic executes a select
> before an update, you'll never see results from the
> update in your select... at least not normally :)
>
> Are you able to access the MySQL monitor program?
>
> if so, verify that the data really does exist
> before running your script (maybe the SELECT
> is failing beucase the actual data is incorrect,
> not the code...)
>
> go into the monitor and execute your SELECT
> statement, then run your PHP script... if
> the results still disagree, post some more
> information...
>
> ----- Original Message -----
> From: "Don Johnson" <don_mail2@mwtb.org>
> To: <php-general@lists.php.net>
> Sent: Wednesday, February 21, 2001 5:19 PM
> Subject: [PHP] MySQL execution order?
>
>
>> Since I've always found my answers in the archive, this is my first post, so
>> please excuse any blunders...
>>
>> 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 General Mailing List (http://www.php.net/)
>> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>> For additional commands, e-mail: php-general-help@lists.php.net
>> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>>