ID:          34719
 Updated by:  [EMAIL PROTECTED]
 Reported By: bouchon at alussinan dot org
-Status:      Open
+Status:      Closed
 Bug Type:    Documentation problem
 PHP Version: Irrelevant
 New Comment:

This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation
better.




Previous Comments:
------------------------------------------------------------------------

[2005-10-03 23:27:03] bouchon at alussinan dot org

Hello,

You are right, the documentation indicates "statement or statements",
but I think that is too discreet (I didn't saw the mention).

Maybe complete that sentence like this : "The SQL statement or
statements (SQL transaction) to be executed."

And/or add a second example "Example 2. pg_query() example using SQL
transaction".

$SQLQuery = 'BEGIN;';
$SQLQuery.= 'INSERT INTO a (a,b) VALUES (1,2);';
$SQLQuery.= 'INSERT INTO b (ref_b,c) VALUES (2,5);';
$SQLQuery.= 'COMMIT;';

$HandleResults = pg_query($SQLQuery);

if (!$HandleResults) {
  echo "An error occured.\n";
  exit;
}

Imho (but it is just my humble opinion), even if that feature is
mentionned, it should be more in evidence.

Best Regards,

------------------------------------------------------------------------

[2005-10-03 19:23:32] [EMAIL PROTECTED]

Take a look at

http://www.postgresql.org/docs/8.0/interactive/libpq-exec.html

"It is allowed to include multiple SQL commands (separated by
semicolons) in the command string. Multiple queries sent in a single
PQexec call are processed in a single transaction, unless there are
explicit BEGIN/COMMIT commands included in the query string to divide
it into multiple transactions. Note however that the returned PGresult
structure describes only the result of the last command executed from
the string. Should one of the commands fail, processing of the string
stops with it and the returned PGresult describes the error
condition."

That means, that if you have explicitly multiple transactions in one
pg_query() invocation, if one of them fails, the execution of the
following commands will also fail. So, generally, it's not a good idea
to use multiple transactions in one pg_query call.

Btw, in the PHP documentation it's described well enough, that
pg_query() accepts "statement or statements".

------------------------------------------------------------------------

[2005-10-03 18:31:15] [EMAIL PROTECTED]

Actually, pg_query() automatically encloses everything in a transaction
block, unless a transaction has already been started - in which case the
queries again fit into one transaction.

However, you're right - it would be good to mention that multiple
queries could be passed to pg_query() and they all are executed as one
transaction.


------------------------------------------------------------------------

[2005-10-03 17:08:46] bouchon at alussinan dot org

Description:
------------
Hello,

I would like to propose to add a short explanation inside the
documentation of the pg_query function, about transactions :

##

Note that the pg_query() function can also take several queries embeded
inside one transaction block.

Example :

$SQLQuery = 'BEGIN;';
$SQLQuery.= 'INSERT INTO a (a,b) VALUES (1,2);';
$SQLQuery.= 'INSERT INTO b (ref_b,c) VALUES (2,5);';
$SQLQuery.= 'COMMIT;';

$HandleResults = pg_query($SQLQuery);


The essential point of a transaction is that it bundles multiple steps
into a single, all-or-nothing operation. You can get more informations
about transaction on
http://www.postgresql.org/docs/8.0/interactive/tutorial-transactions.html
##

I think that this feature should be mentionned inside the pg_query()
function documentation. If this proposal is accepted, feel free to
rewrite it in a better english.

Kind regards,

-- 
Bruno BAGUETTE - [EMAIL PROTECTED]
(hardly filtered mail, but I read answers on the newsgroup) 



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=34719&edit=1

Reply via email to