chenkov [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 19, 2002 5:35 AM
To: Faisal Abdullah
Cc: Marek Kilimajer; PHP
Subject: Re: [PHP] Auto-increment value
Dear Faisal Abdullah,
Once you wrote about "RE: [PHP] Auto-increment value":
> > There is a similar one for postgresq
Dear Faisal Abdullah,
Once you wrote about "RE: [PHP] Auto-increment value":
> > There is a similar one for postgresql as well: pg_last_oid() .
>
> I tried that. It gives me 24807, instead of 5.
> Or is oid is a reference to something else, which would
> lead m
From: Marek Kilimajer <[EMAIL PROTECTED]>
To: PHP <[EMAIL PROTECTED]>
Subject: Re: [PHP] Auto-increment value
You encounter a race condition
bob parker wrote:
>SELECT idno ORDER BY idno DESC LIMIT 1;
>assuming idno
I tend to (if I can't use mysql_last_id) insert a unique key into the row,
and pull the row out that matches that key, in order to get the ID...
ensures that it was the right row... then you can delete the unique key.
Justin
on 18/09/02 10:27 PM, Jon Haworth ([EMAIL PROTECTED]) wrote:
> Hi Bob
653.19)
Content-Type: text/plain;
charset="ISO-8859-1"
Subject: RE: [PHP] Auto-increment value
X-UIDL: *ab"!\-5!!-$7!!nk~!!
Hi Bob,
> SELECT idno ORDER BY idno DESC LIMIT 1;
> assuming idno is what gets auto increm
Hi Bob,
> SELECT idno ORDER BY idno DESC LIMIT 1;
> assuming idno is what gets auto incremented
That's not the best idea - what happens if two users are inserting records
into the table at nearly-but-not-quite the same time?
1. Insert A goes through
2. Insert B goes through
3. LastID A returns
You encounter a race condition
bob parker wrote:
>SELECT idno ORDER BY idno DESC LIMIT 1;
>assuming idno is what gets auto incremented
>bob
>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
SELECT idno ORDER BY idno DESC LIMIT 1;
assuming idno is what gets auto incremented
bob
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
> There is a similar one for postgresql as well: pg_last_oid() .
I tried that. It gives me 24807, instead of 5.
Or is oid is a reference to something else, which would
lead me to the '5' i'm looking for?
-- snip snip --
if($result = pg_exec($db, $sql))
{
$query = "success";
Dear Faisal Abdullah,
Once you wrote about "RE: [PHP] Auto-increment value":
> Thanks for your reply,
> but I'm using postgresql.
> Mysql is irrelevant for me.
There is a similar one for postgresql as well: pg_last_oid() .
> -Original Message-
> From:
Thanks for your reply,
but I'm using postgresql.
Mysql is irrelevant for me.
-Original Message-
From: Marek Kilimajer [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 18, 2002 7:41 PM
To: PHP
Subject: Re: [PHP] Auto-increment value
MySQL has |LAST_INSERT_ID() function, t
gt;-Original Message-
>From: Faisal Abdullah [mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, September 18, 2002 6:37 PM
>To: PHP
>Subject: RE: [PHP] Auto-increment value
>
>
>I tried that. It gives me 24807, instead of 5.
>Or is oid is a reference to something
ther user/session does another insert/nextval(),
before my select statement finishes processing? Would I get
a 5?
Sincerely,
Faisal
-Original Message-
From: Faisal Abdullah [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 18, 2002 6:37 PM
To: PHP
Subject: RE: [PHP] Auto-increment val
d($result);
}
-- snip snip --
Sincerely,
Faisal
-Original Message-
From: Marek Kilimajer [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 18, 2002 5:42 PM
To: PHP
Subject: Re: [PHP] Auto-increment value
As he uses postgresql, he should use *pg_last_oid()*
Scott Houseman wrot
not on postgreSQL :)
Justin
on 18/09/02 7:24 PM, Scott Houseman ([EMAIL PROTECTED]) wrote:
> Hi there.
>
> You can use the function mysql_insert_id( [link id] ).
>
> regards
>
> Scott
>
> Faisal Abdullah wrote:
>> Hi people,
>>
>> I have a table with a column called ID (auto-increment).
>
As he uses postgresql, he should use *pg_last_oid()*
Scott Houseman wrote:
> Hi there.
>
> You can use the function mysql_insert_id( [link id] ).
>
> regards
>
> Scott
>
> Faisal Abdullah wrote:
>
>> Hi people,
>>
>> I have a table with a column called ID (auto-increment).
>> Is it possible to k
Scott Houseman wrote:
> Hi there.
>
> You can use the function mysql_insert_id( [link id] ).
>
>> I'm using postgresql.
Not if you're using PostGreSQL
Grtz Erwin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Hi there.
You can use the function mysql_insert_id( [link id] ).
regards
Scott
Faisal Abdullah wrote:
> Hi people,
>
> I have a table with a column called ID (auto-increment).
> Is it possible to know the value of ID, right after inserting
> a row?
>
> I'm using postgresql.
>
> Thanks.
>
Hi people,
I have a table with a column called ID (auto-increment).
Is it possible to know the value of ID, right after inserting
a row?
I'm using postgresql.
Thanks.
Sincerely,
Faisal
__
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe
19 matches
Mail list logo