X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id D8D8D30FAF3; Wed, 25 Jun 2003 10:05:52 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 21250-01; Wed, 25 Jun 2003 07:05:42 -0300 (ADT) Received: from pow1.ims.telstra.com.au (pow1.ims.telstra.com.au [203.14.14.252]) by svr1.postgresql.org (Postfix) with SMTP id 3192B30FAD4; Wed, 25 Jun 2003 07:05:40 -0300 (ADT) Received: from postgresql.org (h114-8.ims.telstra.com.au [203.18.114.8]) by pow1.ims.telstra.com.au (8.12.9/8.12.9) with ESMTP id h5PA328O007541; Wed, 25 Jun 2003 10:03:03 GMT Message-ID: <3EF973C4.9070009@postgresql.org> Date: Wed, 25 Jun 2003 18:04:52 +0800 From: Justin Clift User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4b) Gecko/20030427 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Rory Campbell-Lange Cc: Bruce Momjian , Josh Berkus , Joe Conway , "Advocacy (PostgreSQL)" , PostgreSQL-general Subject: Re: [GENERAL] interesting PHP/MySQL thread References: <200306211146.41852.josh@agliodbs.com> <200306222159.h5MLxT720807@candle.pha.pa.us> <20030624125933.GD11929@campbell-lange.net> In-Reply-To: <20030624125933.GD11929@campbell-lange.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-MailScanner: Found to be clean X-Archive-Number: 200306/265 X-Sequence-Number: 1477 Hi Rory, Do you want to whip up an initial "improved" set of info to include in the PHP docs as you're mentioning? At least one of the PostgreSQL Community members (Conni) has write access to the official PHP Docs repository and has volunteered to commit improvements like this for us. Regards and best wishes, Justin Clift Rory Campbell-Lange wrote: > I'm a Postgres and PHP newbie. I'm having a great deal of success with > my latest development effort having moved most of the logic from a > perl/php logic 'core' to postgres using plpgsql functions. (Thanks for > all that help, Josh). > > I have a few comments to make on the idea of introducing people, PHP > developers especially, to postgresql. I'm not commenting here on how > easy it is to use PHP with postgres (it was transparent for me using > Debian) or whether or not to advocate the use of advanced features to > general users. Rather, it appears to me, that the PHP/Postgres > documentation and feature set should be improved. > > 1) PHP Documentation > > The postgresql "write up" in the PHP html documentation doesn't give > a very good picture of the capabilities of postgres. While the PHP > docs aren't obviously a good place to write up the benefits of > plpgsql functions, some mention should be made to help differentiate > between the capabilities of MySQL and Postgres. > > PHP documents: > ref.pgsql.html; ref.mysql.html > > The MySQL examples given for database specific functions are useful > and to the point. The page on most of the Postgres functions are > sketchy. (No error number in Postgres...) > > PHP documents: > function.mysql-errno.html; function.pg-result-error.html > > PHP/Postgres provides a set of predefined constants, eg > PGSQL_COMMAND_OK and PGSQL_FATAL_ERROR. The use and parameters of > these constants is not described. The latter appears to provide > inconsistent results under my PHP 4.2.3 install. > > 2) PHP<->Postgres bugs > > Apart from the PGSQL_FATAL_ERROR problem above, it would be good to > find a more simple, PHP-like, approach to catch exceptions and the > like. At the moment I believe one has to do something like: > > function test () { > $sql = " > SELECT > count(n_id) as number > FROM > people > "; > > ob_start(); > $result = pg_exec ($this->conn, $sql); > $this->status = pg_result_status($result); > ob_end_clean(); > > $this->result_checker(); > if ($this->error != 0) { > echo "An error occured.\n"; > exit; > } > ... > return $this; > } > > function result_checker () { > // horrible code to check for postgres exceptions > // status numbers sometimes show up > // ghosts of PGSQL_FATAL_ERROR? > if (! isset($this->status) or > ($this->status == 5 or $this->status == 7)) { > $this->error = 1; > // wierdly, this always works > $this->error_msg = pg_last_error($this->conn); > return 1; > } else { > return 0; > } > } > > > On 22/06/03, Bruce Momjian (pgman@candle.pha.pa.us) wrote: > >>We need to use this opportunity to encourage PHP folks to switch to >>PostgreSQL. > >