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() の例

<?php
// リモートの Firebird サーバーにIPアドレスでアタッチ
if (($service = ibase_service_attach('10.1.1.199', 'sysdba', 'masterkey')) != FALSE) {

// アタッチ成功
// サーバーのバージョン('LI-V3.0.4.33054 Firebird 3.0'のようなもの)を取得
$server_version = ibase_server_info($service, IBASE_SVC_SERVER_VERSION);

// サーバーの実装を取得 ('Firebird/Linux/AMD/Intel/x64' のようなもの)
$server_implementation = ibase_server_info($service, IBASE_SVC_IMPLEMENTATION);

// サーバーからデタッチ(切断)
ibase_service_detach($service);

// 情報を出力
echo "Server version: " . $server_version . "<br/>";
echo
"Server implementation: " . $server_implementation;
}
else {
// エラー時にはメッセージを出力
$conn_error = ibase_errmsg();
die(
$conn_error);
}

?>

例2 hostname/port を使った ibase_service_attach() の例

<?php
// リモートの Firebird サーバーに名前とポート3050を使ってアタッチ
if (($service = ibase_service_attach('FB-SRV-01.contoso.local/3050', 'sysdba', 'masterkey')) != FALSE) {

// アタッチ成功
// サーバーのバージョン('LI-V3.0.4.33054 Firebird 3.0'のようなもの)を取得
$server_version = ibase_server_info($service, IBASE_SVC_SERVER_VERSION);

// サーバーの実装を取得 ('Firebird/Linux/AMD/Intel/x64' のようなもの)
$server_implementation = ibase_server_info($service, IBASE_SVC_IMPLEMENTATION);

// サーバーからデタッチ(切断)
ibase_service_detach($service);

// 情報を出力
echo "Server version: " . $server_version . "<br/>";
echo
"Server implementation: " . $server_implementation;
}
else {
// エラー時にはメッセージを出力
$conn_error = ibase_errmsg();
die(
$conn_error);
}

?>

参考

add a note

User Contributed Notes 3 notes

up
1
Paul Vinkenoog
15 years ago
The previous comment is incorrect. You can connect to the Service Manager as any valid user, and connecting to the Service Manager is not the same as connecting to the security database. However, some of the service functions (which you may subsequently call with the service handle returned by ibase_service_attach) are only available to SYSDBA.
up
0
houston_roadrunner at yahoo dot com
17 years ago
When using this function it looks like you can only use SYSDBA as the user, as you are connecting to the security database. This is a restriction by the interbase/firebird server.
up
0
Anonymous
17 years ago
An example of ibase_service_attach:
<?php
//attach to the server running on localhost
if (($service = ibase_service_attach('localhost', 'sysdba', 'masterkey')) != FALSE) {
//retrieve server info
$server_info = ibase_server_info($service, IBASE_SVC_SERVER_VERSION)
.
' / '
. ibase_server_info($service, IBASE_SVC_IMPLEMENTATION);
//detach from server (disconnect)
ibase_service_detach($service);
}
else {
$ib_error = ibase_errmsg();
}
echo
$server_info;
?>
Should echo something like:

WI-T2.0.0.12484 Firebird 2.0 Release Candidate 1 / Firebird/x86/Windows NT

Taken/adapted from ibWebAdmin source code
To Top