函式名稱:fbird_num_fields()
適用版本:Firebird 1.0.0 及以上版本
用法:fbird_num_fields() 函式用於獲取查詢結果集中的欄位數量。
語法:int fbird_num_fields ( resource $result )
引數:
- result:Firebird 查詢結果集資源。
返回值:返回一個整數,表示查詢結果集中的欄位數量。
示例:
// 建立到 Firebird 資料庫的連線
$db = ibase_connect('localhost:/path/to/database.fdb', 'username', 'password');
// 執行查詢
$query = 'SELECT * FROM employees';
$result = ibase_query($db, $query);
// 獲取查詢結果集中的欄位數量
$fieldCount = fbird_num_fields($result);
echo '查詢結果集中的欄位數量為:' . $fieldCount;
// 釋放結果集資源和資料庫連線
ibase_free_result($result);
ibase_close($db);
以上示例中,我們首先建立到 Firebird 資料庫的連線,然後執行查詢並將結果儲存在 $result 變數中。接下來,我們使用 fbird_num_fields() 函式獲取查詢結果集中的欄位數量,並將結果儲存在 $fieldCount 變數中。最後,我們輸出查詢結果集中的欄位數量。注意,在使用完查詢結果集後,我們需要釋放結果集資源和關閉資料庫連線。