(PHP 4 >= 4.3.0, PHP 5, PHP 7)
pg_update — 锟斤拷锟铰憋拷
$connection
, string $table_name
, array $data
, array $condition
[, int $options
= PGSQL_DML_EXEC
] ) : mixedpg_update() 锟斤拷 condition 锟斤拷为锟斤拷锟斤拷锟斤拷询锟斤拷锟捷库,锟斤拷 data 锟叫碉拷锟斤拷锟捷革拷锟铰凤拷锟斤拷锟斤拷锟斤拷锟侥硷拷录锟斤拷锟斤拷锟街革拷锟斤拷锟� options锟斤拷锟斤拷 pg_convert() 锟结按锟斤拷指锟斤拷选锟斤拷锟斤拷锟矫碉拷 data 锟较★拷
锟剿猴拷锟斤拷锟斤拷实锟斤拷锟斤拷锟侥★拷锟剿猴拷锟斤拷锟侥憋拷锟襟,帮拷锟斤拷锟斤拷锟狡硷拷锟斤拷锟斤拷锟斤拷牡锟斤拷锟斤拷锟斤拷锟斤拷锟轿达拷锟斤拷锟� PHP 锟斤拷锟斤拷锟芥本锟斤拷未通知锟酵憋拷锟睫改★拷使锟矫憋拷锟斤拷锟斤拷锟斤拷锟斤拷锟皆碉拷 锟斤拷
connection
PostgreSQL database connection resource.
table_name
Name of the table into which to update rows.
data
An array whose keys are field names in the table table_name
,
and whose values are what matched rows are to be updated to.
condition
An array whose keys are field names in the table table_name
,
and whose values are the conditions that a row must meet to be updated.
options
Any number of PGSQL_CONV_OPTS
,
PGSQL_DML_NO_CONV
,
PGSQL_DML_EXEC
or
PGSQL_DML_STRING
combined. If PGSQL_DML_STRING
is part of the
options
then query string is returned.
锟缴癸拷时锟斤拷锟斤拷 TRUE
锟斤拷 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE
锟斤拷 Returns string if PGSQL_DML_STRING
is passed
via options
.
Example #1 pg_update() example
<?php
$db = pg_connect('dbname=foo');
$data = array('field1'=>'AA', 'field2'=>'BB');
// This is safe, since $_POST is converted automatically
$res = pg_update($db, 'post_log', $_POST, $data);
if ($res) {
echo "Data is updated: $res\n";
} else {
echo "User must have sent wrong inputs\n";
}
?>