Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.4.1 | 



cubrid_pconnect_with_url

Description

The cubrid_pconnect_with_url function configures the persistent connection to a database server.

The cubrid_pconnect_with_url function is working similar to the cubrid_connect_with_url function but there are two differences as follows:

  • When cubrid_pconnect_with_url function is executed, it looks for a persistent link with the same host, port number, database name, and user name and returns an existing identifier if it exists.
  • The connection made by the cubrid_pconnect_with_url function is maintained although the cubrid_close or cubrid_disconnect function is called.
Syntax

resource cubrid_pconnect_with_url( string $conn_url[, string $userid[, string $passwd]] )

 

<conn_url> ::= [cci:]CUBRID:<host>:<db_name>:<db_user>:<db_password>:[?<properties>]

<properties> ::= <property> [&<property>]

<property> ::= autocommit=<autocommit_mode>

<property> ::= althosts=<alternative_hosts> [ &rctime=<time>]

<property> ::= login_timeout=<milli_sec>

<property> ::= query_timeout=<milli_sec>

<property> ::= disconnect_on_query_timeout=true|false

 

<alternative_hosts> ::= <host>:<port>[, <host>:<port>]

<host> := HOSTNAME | IP_ADDR

 

<time> := SECOND

<milli_sec> := MILLISECOND

  • conn_url : A character string that contains server connection information
    • host : IP address and host name of the Broker Server
    • db_name : Database name
    • db_user : Database user name
    • db_password : Database user password
    • autocommit=true|false : Whether to configure auto-commit mode upon database connection
    • althosts=standby_broker1_host, standby_broker2_host, ... :Specifies the broker information of the standby server, which is used for failover when it is impossible to connect to the active server. You can specify multiple brokers for failover, and the connection to the brokers is attempted in the order listed in alhosts.
      • host : A host name or IP address of the master database
      • port : Port number of a broker server (BROKER_PORT defined in $CUBRID/conf/cubrid_broker.conf)
      • rctime : An interval between the attempts to connect to the active broker in which failure occurred. After a failure occurs, the system connects to the broker specified by althosts (failover), terminates the transaction, and then attempts to connect to the active broker of the master database at every rctime. The default value is 600 seconds.
    • login_timeout : Timeout value (unit : msec.) upon login to a database. If time exceeds the value specified in this parameter, a CCI_ER_LOGIN_TIMEOUT error is returned. The default value is 0, which means infinite wait.
    • query_timeout : Timeout value (unit : msec.). It configures timeout value based on query request. If timeout occurs, a cancellation message of query request, which has been sent to a server, is returned. The return value of a function which executes query is different based on configuration of disconnect_on_query_timeout and the request can succeed even though a cancellation message is sent to a server.
    • disconnect_on_query_timeout : Configures whether to return an error immediately if timeout on the query request happens. The default value is false. If timeout on query request happens and this value is true, a CCI_ER_QUERY_TIMEOUT error is returned after a cancellation message is sent and a socket is disconnected. In this case, a user should close the connection handle to a database explicitly by using the cubrid_disconnect function. If the value is false, a cancellation message is sent and it will wait until a response on query request is made.
  • userid : Database user name
  • passwd : Database user password
Return Value
  • Success : Connection identifier
  • Failure : FALSE
Example

Example #1 cubrid_pconnect_with_url() url without properties example

<?php

$conn_url = "CUBRID:127.0.0.1:33000:demodb:dba:123456:?autocommit=off"

$con = cubrid_pconnect_with_url ($conn_url);

 

if ($con) {

echo "connected successfully";

$req =cubrid_execute($con, "insert into person values(1,'James')");

 

if ($req) { cubrid_close_request ($req); cubrid_commit ($con); } else { cubrid_rollback ($con); }

cubrid_disconnect ($con);

}

?>

 

Example #2 cubrid_pconnect_with_url() url with properties example

<?php

$conn_url = "CUBRID:127.0.0.1:33000:demodb:dba:123456:?autocommit=off&althost=10.34.63.132:33088&rctime=100"

$con = cubrid_pconnect_with_url ($conn_url);

 

if ($con) {

echo "connected successfully";

$req =cubrid_execute($con, "insert into person values(1,'James')");

 

if ($req) { cubrid_close_request ($req); cubrid_commit ($con); } } else { cubrid_rollback ($con); }

cubrid_disconnect ($con);

}

?>