略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: ibase_service_attach

2024-11-12

ibase_service_attach

(PHP 5, PHP 7 < 7.4.0)

ibase_service_attachConnect to the service manager

说明

ibase_service_attach(string $host, string $dba_username, string $dba_password): resource|false

参数

host

The name or ip address of the database host. You can define the port by adding '/' and port number. If no port is specified, port 3050 will be used.

dba_username

The name of any valid user.

dba_password

The user's password.

返回值

Returns a Interbase / Firebird link identifier on success 或者在失败时返回 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($serviceIBASE_SVC_SERVER_VERSION);

        
// Fetch server implementation (something like 'Firebird/Linux/AMD/Intel/x64')
        
$server_implementation ibase_server_info($serviceIBASE_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($serviceIBASE_SVC_SERVER_VERSION);

        
// Fetch server implementation (something like 'Firebird/Linux/AMD/Intel/x64')
        
$server_implementation ibase_server_info($serviceIBASE_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);
    }

?>

参见

add a noteadd a note

User Contributed Notes 3 notes

up
1
Paul Vinkenoog
14 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
16 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
16 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

官方地址:https://www.php.net/manual/en/function.ibase-service-attach.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3