php-doc-en/reference/pgsql/functions/pg-connect.xml
Hartmut Holzgraefe 5b9fc29465 revision tags added
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@78496 c90b9560-bf6c-de11-be94-00142212c4b1
2002-04-17 06:45:35 +00:00

92 lines
3.3 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.2 -->
<refentry id="function.pg-connect">
<refnamediv>
<refname>pg_connect</refname>
<refpurpose>Open a PostgreSQL connection</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>resource</type><methodname>pg_connect</methodname>
<methodparam><type>string</type><parameter>connection_string</parameter></methodparam>
</methodsynopsis>
<para>
<function>pg_connect</function> returns a connection resource
that is needed by other PostgreSQL functions.
</para>
<para>
<function>pg_connect</function> opens a connection to a
PostgreSQL database specified by the
<parameter>connection_string</parameter>. It returns a connection
resource on success. It returns &false; if the connection could
not be made. <parameter>connection_string</parameter> should be
a quoted string.
<example>
<title>Using pg_connect</title>
<programlisting role="php">
<![CDATA[
<?php
$dbconn = pg_connect ("dbname=mary");
//connect to a database named "mary"
$dbconn2 = pg_connect ("host=localhost port=5432 dbname=mary");
// connect to a database named "mary" on "localhost" at port "5432"
$dbconn3 = pg_connect ("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_connect ($conn_string);
//connect to a database named "test" on the host "sheep" with a username and password
?>
]]>
</programlisting>
</example>
The arguments available for
<parameter>connection_string</parameter> includes
<parameter>host</parameter>, <parameter>port</parameter>,
<parameter>tty</parameter>, <parameter>options</parameter>,
<parameter>dbname</parameter>, <parameter>user</parameter>, and
<parameter>password</parameter>.
</para>
<para>
If a second call is made to <function>pg_connect</function> with
the same <parameter>connection_string</parameter>, no
new connection will be established, but instead, the connection
resource of the already opened connection will be returned. You
can have multiple connections to the same database if you use
different connection string.
</para>
<para>
The old syntax with multiple parameters
<command>$conn = pg_connect ("host", "port", "options", "tty", "dbname")
</command> has been deprecated.
</para>
<para>
See also <function>pg_pconnect</function>,
<function>pg_close</function>, <function>pg_host</function>,
<function>pg_port</function>, <function>pg_tty</function>,
<function>pg_options</function> and <function>pg_dbname</function>.
</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:"../../../../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
-->