Re: Inquiry From Form [pgsql]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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.



[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux