我正在尝试获取插入中提交的最后/当前 ID,但我尝试过lastInsertId
但没有奏效。或者returning
,我在插入的末尾使用过。但是那是使用 pg_sql。我将如何使用带有 PDO 的返回线?我坚持在第二个选项中使用 PDO 显示值的逻辑。
php 5.1.6
见下文
不工作
$stmt ->execute();
$newsheetID = $conn->lastInsertId('sheet_id');
echo $newsheetID . "last id";
作品但是是pg_sql,我想让它为PDO工作
$sql = "INSERT INTO sheet_tbl (site_id, username, additionalvolunteers) VALUES ('$_POST[site_id]', '$username','$_POST[additionalvolunteers]') returning sheet_id";
echo $sql;
$result = pg_query($sql);
while ($row = pg_fetch_row($result)) {
$sheet_id_post = $row[0];
echo $sheet_id_post . '<br/>';