Re: Postgres & PHP
| From: | Jouni Ahto | Date: | Sun, 30 Jul 2000 08:34:15 +0000 |
| Subject: | Re: Postgres & PHP | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-1628@lists.php.net to get a copy of this message | ||
On Sun, 30 Jul 2000, Alan Todd wrote:
> What is the proper way to inset values into 2 separate tables
> example
> when they fill out a form that has a place for username, password, first
> and last name
> i want user and pass to be entered into the auth table and the first and
> last name to be entered into users table
$failure = 0;
pg_exec('begin');
if (pg_exec("insert into auth (username, password)
values('$username', '$password')") == FALSE) {
$failure++;
}
if (pg_exec("insert into users (firstname, lastname)
values('$firstname', '$lastname')") == FALSE) {
$failure++;
}
if ($failure) {
pg_exec('rollback');
} else {
pg_exec('commit');
}
-- Jouni Ahto