To make a connection to a firebird database with pconnect many people like to use the SYSDBA, or database owner.
example:
$dbConnection = ibase_pconnect('path to db','SYSDBA','masterkey');
The above is fine unless you want to login in various user that have different permissions. To use permission make roles in the database, either as the database creator (or SYSDBA) and grant the roles to the various users.
If you login with...
$dbConnection = ibase_pconnect('path to db', 'USERNAME', 'userpassword');
...interbase will default your user to the PUBLIC role, which is created when the database is create and usualy has select rights on tables only. To get the proper role you will need to use all the parameters, like this...
$user='USERNAME';
$password='userpassword';
$role='MANAGER_HR';
$dbConnection = ibase_pconnect('path to db', $user, $password, '', 0, 3, $role, 0);
BTW - The "path to db", is formed like this...
---------------------
'localhost:c:/firebird/test_db/test.fdb'
---------------------
reading the interbase material, it states 3 connection methods, PHP appears to have selected the tcp type for us. So you can use localhost, or I suspect(never tested this myself) a ip address.
ibase_pconnect
(PHP 5)
ibase_pconnect — InterBase データベースへの持続的接続をオープンする
説明
$database
[, string $username
[, string $password
[, string $charset
[, int $buffers
[, int $dialect
[, string $role
[, int $sync
]]]]]]]] )InterBase データベースへの持続的な接続をオープンします。
ibase_pconnect() の動作は ibase_connect() と非常に似ていますが、 大きな違いが二つあります。
まず、この関数は接続時に同じパラメータで既にオープンされている (持続的)リンクを探します。見つかった場合、新規接続をオープンする 代わりにそのリンクの ID が返されます。
2 番目の違いとしては、InterBase サーバーへの接続は スクリプト終了時にも閉じられないということです。 代わりに、そのリンクは今後使用するためにオープンされたままとなります ( ibase_close() は ibase_pconnect() によりオープンされたリンクを閉じません)。 このため、この型のリンクは'持続的(persistent)'と呼ばれます。
パラメータ
-
database -
databaseは接続するサーバー上のデータベース ファイルへの正しいパスである必要があります。ローカルなサーバーへの 接続でない場合、使用する接続プロトコルに応じてこの引数の前に' hostname:' (TCP/IP)、'//hostname/' (NetBEUI)、'hostname@' (IPX/SPX)のどれかをつける必要があります。 -
username -
ユーザー名。php.ini ディレクティブ ibase.default_user で設定します。
-
password -
usernameのパスワード。 php.ini ディレクティブ ibase.default_password で設定します。 -
charset -
charsetはデータベースに関するデフォルトの文字セットです。 -
buffers -
buffersはサーバー側のキャッシュに確保されるデータベースバッファの数です。0 または省略された場合、サーバーはデフォルト値を用います。 -
dialect -
dialectは、接続時に実行される全ての命令に 関する SQL 方言のデフォルト値を選択し、デフォルトではクライアント ライブラリでサポートされる方言のうち、最高位のものになります。 InterBase 6 以降でのみ有効です。 -
role -
InterBase 5 以降でのみ有効です。
-
sync -
返り値
成功した場合に InterBase リンク ID、エラー時に FALSE を返します。
