只有我覺得上面的程式碼有誤導性嗎?它讓 odbc_execute() 看起來像是返回一個適合傳遞給 odbc_fetch_* 函式的資源。
事實上,odbc_execute() 返回一個布林值,它僅表示成功 (TRUE) 或失敗 (FALSE)。要傳遞給 odbc_fetch_* 的變數與傳遞給 odbc_execute() 的變數相同。
<?php
$res = odbc_prepare($db_conn, $query_string);
if( !$res ) die( "無法準備敘述句 ".$query_string );
if( odbc_execute($res, $parameters)) {
$row = odbc_fetch_array($res);
} else {
// 處理錯誤
}
?>