From: | will trillich <will(at)serensoft(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: newbie primary key problem |
Date: | 2001-06-21 19:00:10 |
Message-ID: | 20010621140010.C7582@serensoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, Jun 12, 2001 at 05:33:02PM +0100, Dan wrote:
> Hello,
>
> I have a small php script to log web access that writes to a psql database.
> The error I get everytime I do a refresh is:
> Warning: PostgreSQL query failed: ERROR: Cannot insert a duplicate key into
> unique index session_pkey in /var/www/php/web.php on line 22
>
>
> As I understand it the session ID it adds is a primary key and therefore
> cannot be duplicated.
> Can I create another collumn that auto increments a number ( starting with 1
> will be fine ) that can be the primary key/index?
> Firstly is this the best way to do it, also can anyone point me to any
> webpages with rough newbie instructions on this?
sounds like you're setting session id properly, but then you're
trying to insert it into the database every single time, even if
it's a return visit. the logic should look something like
this--
if not exists session-cookie
create session-cookie/session-id
insert session-data into database
else
get session-id from session-cookie
get session-data from database
endif
...
and it's good to have an extra field with a timestamp default, so
you can go through and reap your old sessions after a few weeks.
--
I figure: if a man's gonna gamble, may as well do it
without plowing. -- Bama Dillert, "Some Came Running"
will(at)serensoft(dot)com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!
From | Date | Subject | |
---|---|---|---|
Next Message | Ed Loehr | 2001-06-21 19:05:12 | Re: [GENERAL] Call for alpha testing: planner statistics revisions |
Previous Message | Tom Lane | 2001-06-21 18:58:31 | Re: WAL failure? |