Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B7FAC475DC8 for ; Mon, 18 Nov 2002 12:08:40 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 05F0B475D70 for ; Mon, 18 Nov 2002 12:08:39 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gAIH6QXT020439; Mon, 18 Nov 2002 10:06:26 -0700 (MST) Date: Mon, 18 Nov 2002 10:07:26 -0700 (MST) From: "scott.marlowe" To: William Cc: , "Marc G. Fournier" , Subject: Re: Inquiry From Form [pgsql] In-Reply-To: <20021115222409.C2DD78A1A87@hub.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/76 X-Sequence-Number: 1658 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.