close
例1 返回下一行的第一列
<?php
$sth = $dbh->prepare("SELECT name, colour FROM fruit");
$sth->execute();
/* 從結果集中的下一行獲取第一列 */
print("從結果集中的下一行獲取第一列:\n");
$result = $sth->fetchColumn();
print("name = $result\n");
print("從結果集中的下一行獲取第二列:\n");
$result = $sth->fetchColumn(1);
print("colour = $result\n");
?>
以上例程會輸出:
從結果集中的下一行獲取第一列:
name = lemon
從結果集中的下一行獲取第二列:
colour = red
全站熱搜