PHP8 ibase_service_attach
(PHP 5、PHP 7 < 7.4.0)
ibase_service_attach — 连接到服务管理器
说明
ibase_service_attach(string $host, string $dba_username, string $dba_password): resource|false
参数
host
数据库主机的名称或 IP 地址。您可以通过添加 '/' 和端口号。如果未指定端口,则将使用端口 3050。
dba_username
任何有效用户的名称。
dba_password
用户的密码。
返回值
成功时返回 Interbase / Firebird 链接标识符 或者在失败时返回 false。
示例
示例 #1 ibase_service_attach() example
<?php
// Attach to the remote Firebird server by ip address
if (($service = ibase_service_attach('10.1.1.199', 'sysdba', 'masterkey')) != FALSE) {
// Successfully attached.
// Fetch server version (something like 'LI-V3.0.4.33054 Firebird 3.0')
$server_version = ibase_server_info($service, IBASE_SVC_SERVER_VERSION);
// Fetch server implementation (something like 'Firebird/Linux/AMD/Intel/x64')
$server_implementation = ibase_server_info($service, IBASE_SVC_IMPLEMENTATION);
// Detach from server (disconnect)
ibase_service_detach($service);
// Output the info
echo "Server version: " . $server_version . "<br/>";
echo "Server implementation: " . $server_implementation;
}
else {
// Output message on error
$conn_error = ibase_errmsg();
die($conn_error);
}
?>
示例 #2 ibase_service_attach() example using hostname/port
syntax
<?php
// Attach to the remote Firebird server by name. Use Port 3050.
if (($service = ibase_service_attach('FB-SRV-01.contoso.local/3050', 'sysdba', 'masterkey')) != FALSE) {
// Successfully attached.
// Fetch server version (something like 'LI-V3.0.4.33054 Firebird 3.0')
$server_version = ibase_server_info($service, IBASE_SVC_SERVER_VERSION);
// Fetch server implementation (something like 'Firebird/Linux/AMD/Intel/x64')
$server_implementation = ibase_server_info($service, IBASE_SVC_IMPLEMENTATION);
// Detach from server (disconnect)
ibase_service_detach($service);
// Output the info
echo "Server version: " . $server_version . "<br/>";
echo "Server implementation: " . $server_implementation;
}
else {
// Output message on error
$conn_error = ibase_errmsg();
die($conn_error);
}
?>
参见
- ibase_service_detach() - 断开与服务管理器的连接