From: | "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com> |
---|---|
To: | William <DarkCancerian(at)netscape(dot)net> |
Cc: | <info(at)pgsql(dot)com>, "Marc G(dot) Fournier" <scrappy(at)hub(dot)org>, <pgsql-php(at)postgresql(dot)org> |
Subject: | Re: Inquiry From Form [pgsql] |
Date: | 2002-11-18 17:07:26 |
Message-ID: | Pine.LNX.4.33.0211181004390.17026-100000@css120.ihs.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-php |
On Fri, 15 Nov 2002, William wrote:
> I code with PHP and use it to communicate with MySQL, if I started
> using PostgreSQL would I have to change my coding to communicate with
> the database?
Not really. The only issue is if you used MySQL proprietary stuff.
There's a lot of things in MySQL that are workarounds for it not being a
transactional database that won't work in Postgresql, but using the
"right" method (i.e. a transaction or ANSI SQL) will work just fine.
The only other thing to change is your mysql_xxx commands to pgsql_xxx
commands.
Also, Postgresql doesn't have a pgsql_lastinsert_id like MySQL, instead,
you do it like this:
(Warning pseudocode... :-)
begin;
insert into table yada (field1, field2) values (val1, val2);
select currval('yada_seq');
insert into table yada_child (field1, field2, y_id) values (val1, val2,
y_id);
commit;
i.e. you use currval('seqname') to find out what the id was that was just
inserted.
From | Date | Subject | |
---|---|---|---|
Next Message | scott.marlowe | 2002-11-18 17:12:40 | Re: Inquiry From Form [pgsql] |
Previous Message | Adam Witney | 2002-11-18 10:33:44 | Re: Transaction including two web page + timer |