易洋国学旗下网站:
查询

fbird_connect()函数—用法及示例

「 建立到 Firebird 数据库服务器的连接 」


函数名称:fbird_connect()

适用版本:PHP 4 >= 4.2.0, PHP 5, PHP 7

用法:fbird_connect() 函数用于建立到 Firebird 数据库服务器的连接。

语法:resource fbird_connect ( string $database [, string $username [, string $password [, string $charset [, int $buffers [, int $dialect [, string $role [, int $sync [, int $async [, int $timestamp [, int $lazy ]]]]]]]]]] )

参数:

  • database:要连接的 Firebird 数据库的路径或别名。
  • username:连接数据库的用户名(可选,默认为空字符串)。
  • password:连接数据库的密码(可选,默认为空字符串)。
  • charset:连接数据库时使用的字符集(可选,默认为 NULL)。
  • buffers:指定缓冲区数量(可选,默认为 0)。
  • dialect:指定 SQL 方言(可选,默认为 3)。
  • role:指定连接角色(可选,默认为空字符串)。
  • sync:指定同步模式(可选,默认为 0)。
  • async:指定异步模式(可选,默认为 0)。
  • timestamp:指定时间戳(可选,默认为 0)。
  • lazy:指定懒连接模式(可选,默认为 0)。

返回值:成功时返回一个 Firebird 连接标识符,失败时返回 FALSE。

示例:

<?php
// 建立到 Firebird 数据库的连接
$database = "localhost:C:\path\to\database.fdb";
$username = "myusername";
$password = "mypassword";
$charset = "UTF8";
$buffers = 100;
$dialect = 1;
$role = "myrole";
$sync = 1;
$async = 0;
$timestamp = 1;
$lazy = 0;

$conn = fbird_connect($database, $username, $password, $charset, $buffers, $dialect, $role, $sync, $async, $timestamp, $lazy);

if ($conn) {
    echo "成功建立到 Firebird 数据库的连接";
} else {
    echo "无法连接到 Firebird 数据库";
}
?>
补充纠错
上一个函数: fbird_db_info()函数
下一个函数: fbird_delete_user()函数
热门PHP函数
分享链接