см. http://www.postgresql.org/docs/8.1/static/sql-update.html
UPDATE
users
SET
aboutSelf='...',
hobbies='...',
music='...',
tv='...',
sports='...'
WHERE
email='something'
edit: автономный пример с использованием pg_prepare () :
$pg = pg_connect("dbname=test user=localonly password=localonly");
if ( !$pg ) {
die('connect failed ');
}
// create a temporary/test table
pg_query($pg, '
CREATE TEMPORARY TABLE tmpchatter (
id SERIAL,
email varchar,
aboutSelf varchar,
hobbies varchar,
UNIQUE (email)
)
');
// fill in some test data
pg_query("INSERT INTO tmpchatter(email, aboutSelf, hobbies) VALUES ('emailA','aboutA','hobbiesA')") or die(pq_last_error($pg));
pg_query("INSERT INTO tmpchatter(email, aboutSelf, hobbies) VALUES ('emailB','aboutB','hobbiesB')") or die(pq_last_error($pg));
pg_query("INSERT INTO tmpchatter(email, aboutSelf, hobbies) VALUES ('emailC','aboutC','hobbiesC')") or die(pq_last_error($pg));
// let's see what we've got so far
$result = pg_query('SELECT email,aboutSelf,hobbies FROM tmpchatter') or die(pq_last_error($pg));
echo "query result #1:\n";
while ( false!==($row=pg_fetch_row($result)) ) {
echo join(', ', $row), "\n";
}
// now let's update a specific record
// the "interesting" part
// first the parameters we want to use
$email = 'emailB';
$about = 'about me....';
$hobbies = 'breathing, eating';
// prepare the statement. Put placeholders where you want to "insert" parameters
pg_prepare($pg, '', '
UPDATE
tmpchatter
SET
aboutSelf = $1,
hobbies = $2
WHERE
email = $3
') or die(pg_last_error());
// execute the statement + provide the parameters
// With prepared statements you don't have to worry about escaping the values to avoid sql injections
pg_execute($pg, '', array($about, $hobbies, $email)) or die(pg_last_error());
// let's check the result
$result = pg_query('SELECT email,aboutSelf,hobbies FROM tmpchatter') or die(pq_last_error($pg));
echo "query result #2:\n";
while ( false!==($row=pg_fetch_row($result)) ) {
echo join(', ', $row), "\n";
}
печать
query result #1:
emailA, selfA, hobbiesA
emailB, selfB, hobbiesB
emailC, selfC, hobbiesC
query result #2:
emailA, selfA, hobbiesA
emailC, selfC, hobbiesC
emailB, about me...., breathing, eating