support cubrid_pconnect and cubrid_pconnect_with_url like mysql_pconnect

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@318980 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Esen Sagynov 2011-11-10 08:34:02 +00:00
parent b4210fc438
commit d80d85f8d7
4 changed files with 381 additions and 5 deletions

View file

@ -22,16 +22,23 @@
enabled in CUBRID, you must specify the connection information of the
standby server, which is used for failover when failure occurs, in the url
string argument of this function. If the user name and password is not
given, then the "PUBLIC" connection will be made by default.
given, then the "PUBLIC" connection will be made by default. If a second
call is made to <function>cubrid_connect</function> with the same
<parameter>conn_url</parameter>, and <parameter>userid</parameter> as an
existing connection, the existing connection will be returned unless you
pass.
</para>
<para>
&lt;url&gt; ::= cci:CUBRID:&lt;host&gt;:&lt;db_name&gt;:&lt;db_user&gt;:&lt;db_password&gt;:[?&lt;properties&gt;]
&lt;url&gt; ::= CUBRID:&lt;host&gt;:&lt;db_name&gt;:&lt;db_user&gt;:&lt;db_password&gt;:[?&lt;properties&gt;]
&lt;properties&gt; ::= &lt;property&gt; [&amp;&lt;property&gt;]
&lt;properties&gt; ::= autocommit=&lt;autocommit_mode&gt;
&lt;alternative_hosts&gt; ::= &lt;standby_broker1_host&gt;:&lt;port&gt; [,&lt;standby_broker2_host&gt;:&lt;port&gt;]
&lt;host&gt; := HOSTNAME | IP_ADDR
&lt;time&gt; := SECOND
</para>
<para>
or &lt;url&gt; ::= cci:CUBRID:&lt;host&gt;:&lt;db_name&gt;:......
</para>
<para>
<simplelist>
<member>host : A host name or IP address of the master database</member>
@ -82,7 +89,7 @@
<programlisting role="php">
<![CDATA[
<?php
$conn_url = "cci:CUBRID:127.0.0.1:33088:demodb:dba:123456:?autocommit=off"
$conn_url = "CUBRID:127.0.0.1:33088:demodb:dba:123456:?autocommit=off"
$con = cubrid_connect_with_url ($conn_url);
if ($con) {
@ -107,7 +114,7 @@ if ($con) {
<programlisting role="php">
<![CDATA[
<?php
$conn_url = "cci:CUBRID:127.0.0.1:33088:demodb:dba:123456:?autocommit=off&althost=10.34.63.132:33088&rctime=100"
$conn_url = "CUBRID:127.0.0.1:33088:demodb:dba:123456:?autocommit=off&althost=10.34.63.132:33088&rctime=100"
$con = cubrid_connect_with_url ($conn_url);
if ($con) {
@ -133,7 +140,10 @@ if ($con) {
<para>
<simplelist>
<member><function>cubrid_connect</function></member>
<member><function>cubrid_pconnect</function></member>
<member><function>cubrid_pconnect_with_url</function></member>
<member><function>cubrid_disconnect</function></member>
<member><function>cubrid_close</function></member>
</simplelist>
</para>
</refsect1>

View file

@ -22,7 +22,11 @@
environment for connecting to your server by using your server address,
port number, database name, user name, and password. If the user name and
password is not given, then the "PUBLIC" connection will be made by
default.
default. If a second call is made to <function>cubrid_connect</function>
with the same <parameter>host</parameter>, <parameter>port</parameter>,
<parameter>dbname</parameter> and <parameter>userid</parameter> as an
existing connection, the existing connection will be returned unless you
pass.
</para>
</refsect1>
@ -128,8 +132,11 @@ CUBRID Charset: iso8859-1
&reftitle.seealso;
<para>
<simplelist>
<member><function>cubrid_pconnect</function></member>
<member><function>cubrid_connect_with_url</function></member>
<member><function>cubrid_pconnect_with_url</function></member>
<member><function>cubrid_disconnect</function></member>
<member><function>cubrid_close</function></member>
</simplelist>
</para>
</refsect1>

View file

@ -0,0 +1,182 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 317855 $ -->
<refentry xml:id="function.cubrid-pconnect-with-url" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_pconnect_with_url</refname>
<refpurpose>Open a persistent connection to CUBRID server</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>resource</type><methodname>cubrid_pconnect_with_url</methodname>
<methodparam><type>string</type><parameter>conn_url</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>userid</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>passwd</parameter></methodparam>
</methodsynopsis>
<para>
Establishes a persistent connection to a CUBRID server.
</para>
<para>
<function>cubrid_pconnect_with_url()</function> acts very much like
<function>cubrid_connect_with_url</function> with two major differences.
</para>
<para>
First, when connecting, the function would first try to find a (persistent)
link that's already open with the same host, port, dbname and userid. If
one is found, an identifier for it will be returned instead of opening a
new connection.
</para>
<para>
Second, the connection to the SQL server will not be closed when the
execution of the script ends. Instead, the link will remain open for
future use (<function>cubrid_close</function> or
<function>cubrid_disconnect</function> will not close links established by
<function>cubrid_pconnect_with_url</function>).
</para>
<para>
This type of link is therefore called 'persistent'.
</para>
<para>
&lt;url&gt; ::= CUBRID:&lt;host&gt;:&lt;db_name&gt;:&lt;db_user&gt;:&lt;db_password&gt;:[?&lt;properties&gt;]
&lt;properties&gt; ::= &lt;property&gt; [&amp;&lt;property&gt;]
&lt;properties&gt; ::= autocommit=&lt;autocommit_mode&gt;
&lt;alternative_hosts&gt; ::= &lt;standby_broker1_host&gt;:&lt;port&gt; [,&lt;standby_broker2_host&gt;:&lt;port&gt;]
&lt;host&gt; := HOSTNAME | IP_ADDR
&lt;time&gt; := SECOND
</para>
<para>
or &lt;url&gt; ::= cci:CUBRID:&lt;host&gt;:&lt;db_name&gt;:......
</para>
<para>
<simplelist>
<member>host : A host name or IP address of the master database</member>
<member>db_name : A name of the database</member>
<member>db_user : A name of the database user</member>
<member>db_password : A database user password</member>
<member>autocommit : The database connection auto-commit mode</member>
<member>alhosts: 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</member>
<member>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.</member>
</simplelist>
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>conn_url</parameter></term>
<listitem><para>A character string that contains server connection information.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>userid</parameter></term>
<listitem><para>User name for the database.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>passwd</parameter></term>
<listitem><para>User password.</para></listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Connection identifier, when process is successful.
</para>
<para>
&false;, when process is unsuccessful.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>cubrid_connect_with_url</function> url without properties example</title>
<programlisting role="php">
<![CDATA[
<?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);
}
?>
]]>
</programlisting>
</example>
<example>
<title><function>cubrid_connect_with_url</function> url with properties example</title>
<programlisting role="php">
<![CDATA[
<?php
$conn_url = "CUBRID:127.0.0.1:33000:demodb:dba:123456:?autocommit=off&althost=10.34.63.132:33088&rctime=100"
$con = cubrid_connect_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);
}
?>
]]>
</programlisting>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>cubrid_connect</function></member>
<member><function>cubrid_pconnect</function></member>
<member><function>cubrid_pconnect_with_url</function></member>
<member><function>cubrid_disconnect</function></member>
<member><function>cubrid_close</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,177 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 317827 $ -->
<refentry xml:id="function.cubrid-pconnect" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_pconnect</refname>
<refpurpose>Open a persistent connection to a CUBRID server</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>resource</type><methodname>cubrid_pconnect</methodname>
<methodparam><type>string</type><parameter>host</parameter></methodparam>
<methodparam><type>int</type><parameter>port</parameter></methodparam>
<methodparam><type>string</type><parameter>dbname</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>userid</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>passwd</parameter></methodparam>
</methodsynopsis>
<para>
Establishes a persistent connection to a CUBRID server.
</para>
<para>
<function>cubrid_pconnect()</function> acts very much like
<function>cubrid_connect</function> with two major differences.
</para>
<para>
First, when connecting, the function would first try to find a (persistent)
link that's already open with the same host, port, dbname and userid. If
one is found, an identifier for it will be returned instead of opening a
new connection.
</para>
<para>
Second, the connection to the SQL server will not be closed when the
execution of the script ends. Instead, the link will remain open for
future use (<function>cubrid_close</function> or
<function>cubrid_disconnect</function> will not close links established by
<function>cubrid_pconnect</function>).
</para>
<para>
This type of link is therefore called 'persistent'.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>host</parameter></term>
<listitem><para>Host name or IP address of CUBRID CAS server.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>port</parameter></term>
<listitem><para>Port number of CUBRID CAS server (BROKER_PORT configured in $CUBRID/conf/cubrid_broker.conf).</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>dbname</parameter></term>
<listitem><para>Name of database.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>userid</parameter></term>
<listitem><para>User name for the database.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>passwd</parameter></term>
<listitem><para>User password.</para></listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Connection identifier, when process is successful.
</para>
<para>
&false;, when process is unsuccessful.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>cubrid_connect</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
printf("%-30s %s\n", "CUBRID PHP Version:", cubrid_version());
printf("\n");
$conn = cubrid_pconnect("localhost", 33000, "demodb");
if (!$conn) {
die('Connect Error ('. cubrid_error_code() .')' . cubrid_error_msg());
}
$db_params = cubrid_get_db_parameter($conn);
while (list($param_name, $param_value) = each($db_params)) {
printf("%-30s %s\n", $param_name, $param_value);
}
printf("\n");
$server_info = cubrid_get_server_info($conn);
$client_info = cubrid_get_client_info();
printf("%-30s %s\n", "Server Info:", $server_info);
printf("%-30s %s\n", "Client Info:", $client_info);
printf("\n");
$charset = cubrid_get_charset($conn);
printf("%-30s %s\n", "CUBRID Charset:", $charset);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
CUBRID PHP Version: 8.4.1.0001
PARAM_ISOLATION_LEVEL 3
LOCK_TIMEOUT 0
MAX_STRING_LENGTH 1073741823
PARAM_AUTO_COMMIT 0
Server Info: 8.4.1.0508
Client Info: 8.4.1
CUBRID Charset: iso8859-1
]]>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>cubrid_pconnect</function></member>
<member><function>cubrid_connect_with_url</function></member>
<member><function>cubrid_pconnect_with_url</function></member>
<member><function>cubrid_disconnect</function></member>
<member><function>cubrid_close</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->