1

我有一个选择语句,见下文。使用 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);
4

1 回答 1

1

在 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");
于 2013-08-01T15:36:08.023 回答