mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Document pg_pconnect. Make fix similar to jsgoupil's but in pg_send_query.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@189848 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
25e6912929
commit
20f0b907b9
2 changed files with 86 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.82 -->
|
||||
<refentry id="function.pg-pconnect">
|
||||
<refnamediv>
|
||||
|
@ -20,8 +20,11 @@
|
|||
needed by other PostgreSQL functions.
|
||||
</para>
|
||||
<para>
|
||||
For a description of the <parameter>connection_string</parameter>
|
||||
parameter, see <function>pg_connect</function>.
|
||||
If a second call is made to <function>pg_pconnect</function> with
|
||||
the same <parameter>connection_string</parameter> as an existing connection, the
|
||||
existing connection will be returned unless you pass
|
||||
<constant>PGSQL_CONNECT_FORCE_NEW</constant> as
|
||||
<parameter>connect_type</parameter>.
|
||||
</para>
|
||||
<para>
|
||||
To enable persistent connection, the <link
|
||||
|
@ -40,6 +43,82 @@
|
|||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>connection_string</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The <parameter>connection_string</parameter> can be empty to use all default parameters, or it
|
||||
can contain one or more parameter settings separated by whitespace.
|
||||
Each parameter setting is in the form <literal>keyword = value</literal>. Spaces around
|
||||
the equal sign are optional. To write an empty value or a value
|
||||
containing spaces, surround it with single quotes, e.g., <literal>keyword =
|
||||
'a value'</literal>. Single quotes and backslashes within the value must be
|
||||
escaped with a backslash, i.e., \' and \\.
|
||||
</para>
|
||||
<para>
|
||||
The currently recognized parameter keywords are:
|
||||
<parameter>host</parameter>, <parameter>hostaddr</parameter>, <parameter>port</parameter>,
|
||||
<parameter>dbname</parameter>, <parameter>user</parameter>,
|
||||
<parameter>password</parameter>, <parameter>connect_timeout</parameter>,
|
||||
<parameter>options</parameter>, <parameter>tty</parameter> (ignored), <parameter>sslmode</parameter>,
|
||||
<parameter>requiressl</parameter> (deprecated in favor of <parameter>sslmode</parameter>), and
|
||||
<parameter>service</parameter>. Which of these arguments exist depends
|
||||
on your PostgreSQL version.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>connect_type</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
If <constant>PGSQL_CONNECT_FORCE_NEW</constant> is passed, then a new connection
|
||||
is created, even if the <parameter>connection_string</parameter> is identical to
|
||||
an existing connection.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
PostgreSQL connection resource on success, &false; on failure.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>Using <function>pg_pconnect</function></title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$dbconn = pg_pconnect("dbname=mary");
|
||||
//connect to a database named "mary"
|
||||
|
||||
$dbconn2 = pg_pconnect("host=localhost port=5432 dbname=mary");
|
||||
// connect to a database named "mary" on "localhost" at port "5432"
|
||||
|
||||
$dbconn3 = pg_pconnect("host=sheep port=5432 dbname=mary user=lamb password=foo");
|
||||
//connect to a database named "mary" on the host "sheep" with a username and password
|
||||
|
||||
$conn_string = "host=sheep port=5432 dbname=test user=lamb password=bar";
|
||||
$dbconn4 = pg_pconnect($conn_string);
|
||||
//connect to a database named "test" on the host "sheep" with a username and password
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.11 $ -->
|
||||
<!-- $Revision: 1.12 $ -->
|
||||
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.2 -->
|
||||
<refentry id='function.pg-send-query'>
|
||||
<refnamediv>
|
||||
|
@ -59,7 +59,7 @@
|
|||
echo "$res1 has $rows1 records\n\n";
|
||||
|
||||
$res2 = pg_get_result($dbconn);
|
||||
echo "second call to pg_get_result(): $res2\n";
|
||||
echo "Second call to pg_get_result(): $res2\n";
|
||||
$rows2 = pg_num_rows($res2);
|
||||
echo "$res2 has $rows2 records\n";
|
||||
?>
|
||||
|
@ -68,10 +68,10 @@
|
|||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
first call to pg_get_result(): Resource id #3
|
||||
First call to pg_get_result(): Resource id #3
|
||||
Resource id #3 has 3 records
|
||||
|
||||
second call to pg_get_result(): Resource id #4
|
||||
Second call to pg_get_result(): Resource id #4
|
||||
Resource id #4 has 1 records
|
||||
]]>
|
||||
</screen>
|
||||
|
|
Loading…
Reference in a new issue