RE: [PHP-WIN] MySQL / PHP - possible to run many sql statements in the same execution?
| From: | Matt Babineau | Date: | Thu, 25 Apr 2002 20:59:47 +0000 |
| Subject: | RE: [PHP-WIN] MySQL / PHP - possible to run many sql statements in the same execution? | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-13315@lists.php.net to get a copy of this message | ||
Well, when I tested the code, It was still allowing 2 requests to
update/read the table at the same time. It may only be in the case tha
tI am facing when I am updating the table but also need to output the
new value that was updated. I may just be attacking this problem wrong
too.
Matt Babineau
Freelance Internet Developer
e: mbabineau@illuminatistudios.com
p: 603.943.4237
w: http://www.illuminatistudios.com
-----Original Message-----
From: Scott Hurring [mailto:scott@eacnet.com]
Sent: Thursday, April 25, 2002 4:49 PM
To: Php-Win (E-mail)
Subject: RE: [PHP-WIN] MySQL / PHP - possible to run many sql statements
in the same execution?
Sorry for seeming a bit dense, but what's the problem
with using "LOCL TABLES" for all SQL stmnts?
It's my understanding that it will lock tables
and prevent other procs from reading/writing to
that table while you've got a lock on it.
Is that not the case?
---
Scott Hurring
Systems Programmer
EAC Corporation
ScottH@eac.com
Voice: 201-462-2149
Fax: 201-288-1515
> -----Original Message-----
> From: Matt Babineau [mailto:matt@criticalcode.com]
> Sent: Thursday, April 25, 2002 3:46 PM
> To: 'Php-Win (E-mail)'
> Subject: [PHP-WIN] MySQL / PHP - possible to run many sql
> statements in
> the same execution?
>
>
> Let me try and explain a little better:
>
> Here is some query code
>
> $query3 = "LOCK TABLES COUNTER_PAGE_VIEWS";
> $query = "SELECT Count FROM COUNTER_Page_Views WHERE Counter_ID = '" .
> $count_id . "'"; $query1 = "UPDATE COUNTER_Page_Views SET Count =
> Count + 1 WHERE Counter_ID = '" . $count_id . "'";
> $result3 = mysql_query($query3);
> $result1 = mysql_query($query1);
> $result = mysql_query($query);
>
>
> As the page processes, it processes in order, so it owuld go through
> those lines of code and do what it needs to do. Currently two users
> can cause a threading issue where even if I lock the table,
> because the call
> is not coming from inside MySQL. So the locking only occurs for the
> single Query which locks the Table, then the next query
> execution voids
> the write lock on the table.
>
> What I would need to do here is either lump all the queryioes into one
> SQL execution or lock the PHP code so it is single threaded like this:
>
> $query3 = "LOCK TABLES COUNTER_PAGE_VIEWS";
> $query = "SELECT Count FROM COUNTER_Page_Views WHERE Counter_ID = '" .
> $count_id . "'"; $query1 = "UPDATE COUNTER_Page_Views SET Count =
> Count + 1 WHERE Counter_ID = '" . $count_id . "'";
>
> <LOCK THE CODE SO ONLY ONE CLIENT CAN RUN AT A TIME>
> $result3 = mysql_query($query3);
> $result1 = mysql_query($query1);
> $result = mysql_query($query);
> <RELEASE THE LOCK>
>
> Anyone have any suggestions?
>
> Matt Babineau
> Freelance Internet Developer
> e: <mailto:mbabineau@illuminatistudios.com>
> mbabineau@illuminatistudios.com
> p: 603.943.4237
> w: <http://www.illuminatistudios.com/>
http://www.illuminatistudios.com
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php