函數(shù)名:fbird_param_info()
適用版本:Firebird 2.0.0 及以上版本
用法:fbird_param_info() 函數(shù)用于獲取 Firebird 查詢中參數(shù)的相關(guān)信息。
參數(shù):
- $query_handle:必需,F(xiàn)irebird 查詢的句柄。
返回值: 該函數(shù)返回一個數(shù)組,包含以下信息:
- name:參數(shù)的名稱
- alias:參數(shù)的別名
- relation:參數(shù)所屬的關(guān)系
- precision:參數(shù)的精度
- scale:參數(shù)的刻度
- subtype:參數(shù)的子類型
- length:參數(shù)的長度
- charset:參數(shù)的字符集
- nullable:參數(shù)是否可為 NULL
- type:參數(shù)的類型
示例:
<?php
// 連接到 Firebird 數(shù)據(jù)庫
$conn = ibase_connect($host, $username, $password, $charset);
// 準(zhǔn)備查詢語句
$query = 'SELECT * FROM customers WHERE age < ? AND city = ?';
// 準(zhǔn)備參數(shù)
$param1 = 30;
$param2 = 'New York';
// 準(zhǔn)備查詢句柄
$queryHandle = ibase_prepare($conn, $query);
// 綁定參數(shù)
ibase_bind_param($queryHandle, 1, $param1);
ibase_bind_param($queryHandle, 2, $param2);
// 執(zhí)行查詢
$result = ibase_execute($queryHandle);
// 獲取參數(shù)信息
$paramInfo = fbird_param_info($queryHandle);
// 打印參數(shù)信息
print_r($paramInfo);
// 關(guān)閉連接
ibase_close($conn);
?>
輸出:
Array
(
[0] => Array
(
[name] => ?
[alias] =>
[relation] =>
[precision] =>
[scale] =>
[subtype] =>
[length] => 0
[charset] =>
[nullable] => 1
[type] => 7
)
[1] => Array
(
[name] => ?
[alias] =>
[relation] =>
[precision] =>
[scale] =>
[subtype] =>
[length] => 0
[charset] =>
[nullable] => 1
[type] => 14
)
)
注意:在示例中,我們假設(shè)已經(jīng)成功連接到 Firebird 數(shù)據(jù)庫,并已經(jīng)定義了 $host
、$username
、$password
和 $charset
變量。