RE: [PHP] Re: Thread safe
| From: | Scott Hurring | Date: | Tue, 28 May 2002 16:54:04 +0000 |
| Subject: | RE: [PHP] Re: Thread safe | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-99512@lists.php.net to get a copy of this message | ||
I'm not sure if it's atomic, but (AFAIK) you can
do something like this with Mysql:
UPDATE table SET field=field+1 where .....
---
Scott Hurring
Systems Programmer
EAC Corporation
ScottH@eac.com
Voice: 201-462-2149
Fax: 201-288-1515
> -----Original Message-----
> From: J Smith [mailto:dark_panda@hushmail.com]
> Sent: Monday, May 27, 2002 12:49 PM
> To: php-general@lists.php.net
> Subject: [PHP] Re: Thread safe
>
>
>
> You could use a transaction block if your database supports
> it, or just use
> some sort of auto-numbering field, such as SERIAL in Postgres,
> auto_increment in MySQL, etc. Then you wouldn't have to worry about
> retrieving the next cno before inserting a new row.
>
> J
>
>
> R wrote:
>
> > Hi,
> > In java servlets I used to use a "synchronised" block of
> code to make
> sure
> > it was thread safe...how do i do this in PHP?
> >
> > Heres what should be thread safe
> >
> > {
> > $r=select max(cno)+1 from MyTable;
> > (then i insert into the table the new cno plus my name)
> > insert into mytable ($r,'myname');
> > }
> > How to do this and make sure its thread safe?
> >
> > Any help appreciated,
> > -Ryan
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>