gpt4 book ai didi

sql - 从 PG_query 移动到 PDO 的 SELECT 问题

转载 作者:行者123 更新时间:2023-11-29 13:33:46 24 4
gpt4 key购买 nike

我有一个 select 语句,见下文。使用 PDO 我将如何重新创建相同的 Select 语句,因为我想从中获取两个值并将它们组合到 $geomstring 中。我可以算出组合,但不能算出前 3 行。

$sql1 = "SELECT easting_value, northing_value FROM gridreference_tbl WHERE gridref_id='$_POST[gridref_id]'";
$result1 = pg_query($sql1);
$row1 = pg_fetch_array($result1);

$geomstring = $row1['easting_value']. $_POST['grid_eastings']." ".$row1['northing_value'].$_POST['grid_northings'];

*准备语句的 php 网站说 *

$stmt = $dbh->prepare("SELECT * FROM REGISTRY where name = ?");
if ($stmt->execute(array($_GET['name']))) {
while ($row = $stmt->fetch()) {
print_r($row);
}
}

我有类似的东西来填充部分使用这个的下拉菜单

$stmt = $conn->prepare("SELECT easting_value, northing_value FROM gridreference_tbl WHERE gridref_id=$gridref_id");
$stmt->setFetchMode(PDO::FETCH_OBJ);

最佳答案

在 php.net 上找到的,我在谷歌上搜索了错误的东西:

$stmt4 = $conn->prepare("SELECT easting_value, northing_value from gridreference_tbl WHERE gridref_id = 4");
$stmt4->execute();
print("PDO::FETCH_ASSOC: ");
print("Return next row as an array indexed by column name\n");
$result = $stmt4->fetch(PDO::FETCH_ASSOC);
print_r($result);
print("\n");

关于sql - 从 PG_query 移动到 PDO 的 SELECT 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17997899/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com