Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.3.0 |  CUBRID 8.3.1 |  CUBRID 8.4.0 |  CUBRID 8.4.1 | 



The cubrid_connect_with_url function tries to connect a database by using connection information passed with a url string argument. If CUBRID HA is enabled in PHP, you must specify connection information of the active server and connection information of the standby server, which is used for failover when failure occurs, in the url string argument of this function.


resource cubrid_connect_with_url (string $conn_url [, string $db_user, string $db_password[, bool $new_link]])


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

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

<property> ::= login_timeout=<milli_sec>

<property> ::= query_timeout=<milli_sec>

<property> ::= disconnect_on_query_timeout=true|false

<property> ::= autocommit=<autocommit_mode>

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

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

<host> := HOSTNAME | IP_ADDR

<time> := SECOND

  • conn_url : A character string that contains server connection information
    • host : A host name or IP address of the master database
    • db_name : A name of the database
    • db_user : (IN) A name of the database user
    • db_password : A database user password
    • login_timeout : Timeout value (unit : msec.) upon login to a database. If time exceeds the value specified in this parameter, an 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, an 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.
    • autocommit=true/false : The database connection auto commit mode.
    • 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 althosts.
    • 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.
  • db_user : A name of the database user
  • db_passwd : A database user password
  • new_link : Whether to re-use an existing connection if an environment is identical in one HTTP request. If the value is true, a new connection identifier is created; if false and a connection with the same address, port number, database name, and user name exists, the existing connection is used. Note that this option is only valid within HTTP request; when HTTP request is closed, all connections are closed as well.
Return Value
  • Success : Connection identifier
  • Failure : FALSE


$con = cubrid_connect_with_url("cci:CUBRID:localhost:33000:demodb:dba::?autocommit=true");



Because a colon (:) and a question mark (?) is used as a separator in URL string, it is not allowed to include them for password of URL string. To use them, you must specify a user name (db_user) and a password (db_password) as a separate parameter.