conni Mon Jul 14 19:39:08 2003 EDT
Modified files:
/phpdoc/en/reference/pgsql/functions pg-affected-rows.xml
pg-convert.xml pg-insert.xml
pg-dbname.xml pg-close.xml
pg-connect.xml
pg-connection-reset.xml
Log:
unified examples, fixed typos, some new examples ...
Index: phpdoc/en/reference/pgsql/functions/pg-affected-rows.xml
diff -u phpdoc/en/reference/pgsql/functions/pg-affected-rows.xml:1.2
phpdoc/en/reference/pgsql/functions/pg-affected-rows.xml:1.3
--- phpdoc/en/reference/pgsql/functions/pg-affected-rows.xml:1.2 Wed Apr 17
02:43:12 2002
+++ phpdoc/en/reference/pgsql/functions/pg-affected-rows.xml Mon Jul 14 19:39:08
2003
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.2 -->
<refentry id="function.pg-affected-rows">
<refnamediv>
<refname>pg_affected_rows</refname>
- <refpurpose>Returns number of affected records(tuples)</refpurpose>
+ <refpurpose>Returns number of affected records (tuples)</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
@@ -17,12 +17,14 @@
(instances/records/rows) affected by INSERT, UPDATE, and DELETE
queries executed by <function>pg_query</function>. If no tuple is
affected by this function, it will return 0.
+ </para>
+ <para>
<example>
<title><function>pg_affected_rows</function></title>
<programlisting role="php">
<![CDATA[
<?php
- $result = pg_query ($conn, "INSERT INTO publisher VALUES ('Author')");
+ $result = pg_query ($conn, "INSERT INTO authors VALUES ('Orwell', 2002, 'Animal
Farm')");
$cmdtuples = pg_affected_rows ($result);
echo $cmdtuples . " tuples are affected.";
?>
Index: phpdoc/en/reference/pgsql/functions/pg-convert.xml
diff -u phpdoc/en/reference/pgsql/functions/pg-convert.xml:1.4
phpdoc/en/reference/pgsql/functions/pg-convert.xml:1.5
--- phpdoc/en/reference/pgsql/functions/pg-convert.xml:1.4 Sat Feb 22 18:22:15
2003
+++ phpdoc/en/reference/pgsql/functions/pg-convert.xml Mon Jul 14 19:39:08 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.80 -->
<refentry id='function.pg-convert'>
<refnamediv>
@@ -18,7 +18,14 @@
<methodparam
choice="opt"><type>int</type><parameter>options</parameter></methodparam>
</methodsynopsis>
<para>
- <function>pg_convert</function> check and convert <literal>assoc_array</literal>
suitable for SQL statement.
+ <function>pg_convert</function> checks and converts the values in
+ <literal>assoc_array</literal> into suitable values for use in a SQL
+ statement. Precondition for <function>pg_convert</function> is the existence
+ of a table <literal>table_name</literal> which has at least as many columns
+ as <literal>assoc_array</literal> has elements. The fieldnames as well as
+ the fieldvalues in <literal>table_name</literal> must match the indices and
+ values of <literal>assoc_array</literal>. Returns an array with the converted
+ values on success, &false; otherwise.
</para>
<note>
<para>
Index: phpdoc/en/reference/pgsql/functions/pg-insert.xml
diff -u phpdoc/en/reference/pgsql/functions/pg-insert.xml:1.5
phpdoc/en/reference/pgsql/functions/pg-insert.xml:1.6
--- phpdoc/en/reference/pgsql/functions/pg-insert.xml:1.5 Thu Aug 22 08:26:11
2002
+++ phpdoc/en/reference/pgsql/functions/pg-insert.xml Mon Jul 14 19:39:08 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.5 $ -->
+<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.80 -->
<refentry id='function.pg-insert'>
<refnamediv>
@@ -18,21 +18,23 @@
<methodparam
choice="opt"><type>int</type><parameter>options</parameter></methodparam>
</methodsynopsis>
<para>
- <function>pg_insert</function> inserts
- <literal>assoc_array</literal> which has
- <literal>field=>value</literal> into table specified as
- <literal>table_name</literal>. If <literal>options</literal> is
- specified, <function>pg_convert</function> is applied
- to <literal>assoc_array</literal> with specified option.
+ <function>pg_insert</function> inserts the values of
<literal>assoc_array</literal>
+ into the table specified by <literal>table_name</literal>.
+ <literal>table_name</literal> must at least have as many columns as
<literal>assoc_array</literal>
+ has elements. The fieldnames as well as the fieldvalues in
<literal>table_name</literal>
+ must match the indices and values of <literal>assoc_array</literal>.
+ <function>pg_insert</function> returns &true; on success, &false; on failure.
+ If options is specified, <function>pg_insert</function> is applied to
+ <literal>assoc_array</literal> with specified option.
</para>
<example>
<title>pg_insert</title>
<programlisting role="php">
<![CDATA[
<?php
- $db = pg_connect ('dbname=foo');
+ $dbconn = pg_connect ('dbname=foo');
// This is safe, since $_POST is converted automatically
- $res = pg_insert($db, 'post_log', $_POST);
+ $res = pg_insert($dbconn, 'post_log', $_POST);
if ($res) {
echo "POST data is succesfully logged\n";
}
Index: phpdoc/en/reference/pgsql/functions/pg-dbname.xml
diff -u phpdoc/en/reference/pgsql/functions/pg-dbname.xml:1.2
phpdoc/en/reference/pgsql/functions/pg-dbname.xml:1.3
--- phpdoc/en/reference/pgsql/functions/pg-dbname.xml:1.2 Wed Apr 17 02:43:18
2002
+++ phpdoc/en/reference/pgsql/functions/pg-dbname.xml Mon Jul 14 19:39:08 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.2 -->
<refentry id="function.pg-dbname">
<refnamediv>
@@ -17,6 +17,21 @@
that the given PostgreSQL <parameter>connection</parameter>
resource. It returns &false;, if <parameter>connection</parameter>
is not a valid PostgreSQL connection resource.
+ </para>
+ <para>
+ <example>
+ <title><function>pg_dbname</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ error_reporting(E_ALL);
+
+ pg_connect ("host=localhost port=5432 dbname=mary");
+ echo pg_dbname();
+?>
+]]>
+ </programlisting>
+ </example>
</para>
</refsect1>
</refentry>
Index: phpdoc/en/reference/pgsql/functions/pg-close.xml
diff -u phpdoc/en/reference/pgsql/functions/pg-close.xml:1.2
phpdoc/en/reference/pgsql/functions/pg-close.xml:1.3
--- phpdoc/en/reference/pgsql/functions/pg-close.xml:1.2 Wed Apr 17 02:43:15
2002
+++ phpdoc/en/reference/pgsql/functions/pg-close.xml Mon Jul 14 19:39:08 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.82 -->
<refentry id="function.pg-close">
<refnamediv>
@@ -24,6 +24,21 @@
of the script.
</para>
</note>
+ <para>
+ <example>
+ <title>PostgreSQL close example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $dbconn = $dbconn = pg_connect ("host=localhost port=5432 dbname=mary")
+ or die("Could not connect);
+ print ("Connected successfully");
+ pg_close($dbconn);
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
<para>
If there is open large object resource on the connection, do not
close the connection before closing all large object resources.
Index: phpdoc/en/reference/pgsql/functions/pg-connect.xml
diff -u phpdoc/en/reference/pgsql/functions/pg-connect.xml:1.2
phpdoc/en/reference/pgsql/functions/pg-connect.xml:1.3
--- phpdoc/en/reference/pgsql/functions/pg-connect.xml:1.2 Wed Apr 17 02:43:15
2002
+++ phpdoc/en/reference/pgsql/functions/pg-connect.xml Mon Jul 14 19:39:08 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.2 -->
<refentry id="function.pg-connect">
<refnamediv>
@@ -30,10 +30,13 @@
<?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
@@ -54,7 +57,7 @@
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.
+ different connection strings.
</para>
<para>
The old syntax with multiple parameters
Index: phpdoc/en/reference/pgsql/functions/pg-connection-reset.xml
diff -u phpdoc/en/reference/pgsql/functions/pg-connection-reset.xml:1.2
phpdoc/en/reference/pgsql/functions/pg-connection-reset.xml:1.3
--- phpdoc/en/reference/pgsql/functions/pg-connection-reset.xml:1.2 Wed Apr 17
02:43:15 2002
+++ phpdoc/en/reference/pgsql/functions/pg-connection-reset.xml Mon Jul 14 19:39:08
2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.82 -->
<refentry id='function.pg-connection-reset'>
<refnamediv>
@@ -17,6 +17,25 @@
<para>
<function>pg_connection_reset</function> resets the connection.
It is useful for error recovery. &return.success;
+ </para>
+ <para>
+ <example>
+ <title><function>pg_connection_reset</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $dbconn = pg_connect("dbname=publisher") or die ("Could not connect");
+ $dbconn2 = pg_connection_reset($dbconn);
+ if ($dbconn2) {
+ echo 'reset successful';
+ }
+ else {
+ echo 'reset failed';
+ }
+?>
+]]>
+ </programlisting>
+ </example>
</para>
<para>
See also <function>pg_connect</function>,
--
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php