Greetings To <pgsql-general@xxxxxxxxxxxxxx>:
I am migrating a PHP web application to use
PostgreSQL instead of MySQL.
And I have never used PostgreSQL before. I have two questions about function pg_result_error_field(...);
An extensive search of the web, did not yield a
solution to my problem.
* * *
* * *
My PHP program is using the PHP pg_* PostgreSQL
functions.
The test environment is Windows XP SP3
with: PostgreSQL 9.3, Apache 2.2.14 and PHP 5.3.1.
The file php.ini has a line extension = php_pgsql.dll
phpinfo() shows (when my PHP program is
not running):
* * *
* * *
In the PHP program:
$sql_conn =
pg_connect(...); // returns a value of type resource.
pg_connection_status($sql_conn); // returns an integer
type with a value == 0 (PGSQL_CONNECTION_OK).
pg_send_query($sql_conn,
'BEGIN;'); // returns a boolean type with a value == TRUE.
$sql_result = pg_get_result($sql_conn); // returns a value of type resource. $sql_state =
pg_result_error_field($sql_result, PGSQL_DIAG_SQLSTATE); //
returns a boolean type with a value == FALSE, instead of a string type with a
SQLSTATE value.
My question #1 is: should BEGIN; END;
& ROLLBACK; commands return a result with a SQLSTATE value
available?
* * *
* * *
Additional investigation reveals that every call to function pg_result_error_field($sql_result, ...); with a different constant for the fieldcode
parameter, returns a boolean type == FALSE, instead of a meaningful value for
the corresponding field:
According to web page http://www.icosaedro.it/phplint/phplint2/doc/modules/pgsql.html the
values of the constants are not the same as the constant values my PHP program
shows:
I note that the constant values listed on
the web page, are in a tight strict ascending sequence from 23 ... 34, whereas
the values obtained by my program are scattered.
Perhaps the values of the constants being obtained by my PHP
program are not correct?
Question #2: Is there a PHP source code
module my program needs to 'require' to obtain the correct constant
values?
Any comments / suggestions would be
appreciated.
Thanks,
Steve
|