用php代码编写,有pg_Inquiry(id )和pg_InquiryDetail(id, inquiry_id,full_estate_name,size,usage,zd_bh,zd_area,zd_price,zd_build_price)表,pg_InquiryDetail.inquiry_id跟,pg_Inquiry.id关联。现传入inquiry_id 和 full_estate_name,更新pg_InquiryDetail指定inquiry_id和full_estate_name都完全一致的pg_InquiryDetail数据
时间: 2023-07-05 18:27:45 浏览: 85
pg_hashids:PostgreSQL短唯一ID生成器,使用哈希值
可以使用以下PHP代码来更新pg_InquiryDetail表中指定inquiry_id和full_estate_name都完全一致的数据:
```php
<?php
// 连接数据库
$conn = pg_connect("host=localhost port=5432 dbname=mydatabase user=myusername password=mypassword");
// 获取要更新的inquiry_id和full_estate_name
$inquiry_id = $_POST['inquiry_id'];
$full_estate_name = $_POST['full_estate_name'];
// 获取要更新的字段值
$size = $_POST['size'];
$usage = $_POST['usage'];
$zd_bh = $_POST['zd_bh'];
$zd_area = $_POST['zd_area'];
$zd_price = $_POST['zd_price'];
$zd_build_price = $_POST['zd_build_price'];
// 执行SQL语句
$sql = "UPDATE pg_InquiryDetail SET size = $1, usage = $2, zd_bh = $3, zd_area = $4, zd_price = $5, zd_build_price = $6 WHERE inquiry_id = $7 AND full_estate_name = $8";
$result = pg_query_params($conn, $sql, array($size, $usage, $zd_bh, $zd_area, $zd_price, $zd_build_price, $inquiry_id, $full_estate_name));
if (!$result) {
echo "更新失败";
} else {
echo "更新成功";
}
// 关闭数据库连接
pg_close($conn);
?>
```
其中,将`mydatabase`、`myusername`和`mypassword`替换为你的数据库名称、用户名和密码。在实际应用中,需要根据具体情况修改代码。
阅读全文