用php代码编写,有pg_Inquiry(id )和pg_InquiryDetail(id, inquiry_id,full_estate_name)表,pg_InquiryDetail.inquiry_id跟,pg_Inquiry.id关联。现传入inquiry_id 和 full_estate_name,更新pg_InquiryDetail指定inquiry_id和full_estate_name都完全一致的pg_InquiryDetail数据
时间: 2023-07-05 07:27:44 浏览: 92
可以使用以下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'];
// 执行SQL语句
$sql = "UPDATE pg_InquiryDetail SET full_estate_name = $1 WHERE inquiry_id = $2 AND full_estate_name = $3";
$result = pg_query_params($conn, $sql, array('new_full_estate_name', $inquiry_id, $full_estate_name));
if (!$result) {
echo "更新失败";
} else {
echo "更新成功";
}
// 关闭数据库连接
pg_close($conn);
?>
```
其中,将`mydatabase`、`myusername`和`mypassword`替换为你的数据库名称、用户名和密码。将`new_full_estate_name`替换为要更新的新full_estate_name。在实际应用中,需要根据具体情况修改代码。
阅读全文