From e953ab37e26656d4481084d5d3ef65bd4eb06150 Mon Sep 17 00:00:00 2001 From: Yasuo Ohgaki Date: Mon, 10 Dec 2001 16:23:48 +0000 Subject: [PATCH] More protos are fixed. Descrptions are added/updated. - php.ini, see also, etc pg_last_notice() added. Added warning for "last message handling" bug. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@64440 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/pgsql.xml | 857 +++++++++++++++++++++++++++++--------------- 1 file changed, 575 insertions(+), 282 deletions(-) diff --git a/functions/pgsql.xml b/functions/pgsql.xml index e49e340a02..b7c46adeeb 100644 --- a/functions/pgsql.xml +++ b/functions/pgsql.xml @@ -1,29 +1,61 @@ - + PostgreSQL functions PostgreSQL + + + Use of PostgreSQL module with PHP 4.0.6 is not recommended due to + a bug in notice message handling. + + - Postgres, developed originally in the UC Berkeley Computer Science + Postgres, developed originally in the UC Berkeley Computer Science Department, pioneered many of the object-relational concepts now becoming available in some commercial databases. It provides - SQL92/SQL3 language support, transaction integrity, and type + SQL92/SQL3 language support, transaction integrity and type extensibility. PostgreSQL is an open source descendant of this original Berkeley code. - PostgreSQL is available without cost. The current version is - available at www.PostgreSQL.org. + PostgreSQL database is Open Source product and available without + cost. To use PostgreSQL support, you need PostgreSQL 6.5 or + later. PostgreSQL 7.0 or later to enable all PostgreSQL module + feature. PostgreSQL supports many charactor encoding including + multibyte character encoding. The current version and more + information about PostgreSQL is available at www.postgresql.org. - Since version 6.3 (03/02/1998) PostgreSQL uses unix domain sockets. - A table is shown below describing these new connection possibilities. - This socket will be found in /tmp/.s.PGSQL.5432. - This option can be enabled with the '-i' flag to postmaster - and it's meaning is: "listen on TCP/IP sockets as well as - Unix domain sockets". + In order to enable PostgreSQL support, + "--enable-pgsql[=DIR]" is required when you compile + PHP. If shared object module is available, PostgreSQL module may + be loaded using extension + directive in php.ini or dl + function. Supported ini directives are described in php.ini-dist + file which comes with source distribution. + + + Not all functions are supported by all builds. It depends on your + libpq (The PostgreSQL C Client interface) versoin and how libpq is + compiled. If there is missing function, libpq does not support + the feature required for the function. + + + It is also important that you use newer libpq than PostgreSQL + Server to be connected. If you use libpq older than PostgreSQL + Server expects, you may have problems. + + + Since version 6.3 (03/02/1998) PostgreSQL uses unix domain sockets + by default. TCP port will not be openned by default. A table is + shown below describing these new connection possibilities. This + socket will be found in /tmp/.s.PGSQL.5432. + This option can be enabled with the '-i' flag to + postmaster and it's meaning is: "listen on + TCP/IP sockets as well as Unix domain sockets". Postmaster and PHP @@ -42,7 +74,6 @@ postmaster -i & - pg_connect("dbname=MyDbName"); OK @@ -53,7 +84,7 @@ Unable to connect to PostgreSQL server: connectDB() failed: Is the postmaster running and accepting TCP/IP (with -i) connection at 'localhost' on port '5432'? in - /path/to/file.php3 on line 20. + /path/to/file.php on line 20. @@ -66,44 +97,60 @@
- One can establish a connection with the following value pairs - set in the command string: - $conn = pg_Connect("host=myHost port=myPort tty=myTTY - options=myOptions dbname=myDB user=myUser password=myPassword "); + A connection to PostgreSQL server can be established with the + following value pairs set in the command string: $conn = + pg_connect("host=myHost port=myPort tty=myTTY options=myOptions + dbname=myDB user=myUser password=myPassword "); The previous syntax of: - $conn = pg_connect ("host", "port", "options", "tty", - "dbname") + + $conn = pg_connect ("host", "port", "options", "tty", "dbname") has been deprecated. - To use the large object (lo) interface, it is necessary to enclose - it within a transaction block. A transaction block starts with a - begin and if the transaction was valid ends - with commit or end. If the - transaction fails the transaction should be closed with - rollback or abort. + Environmental variable affects PostgreSQL server/client + behavior. For example, PostgreSQL module will lookup PGHOST + environment variable when hostname is omitted in connection + string. Supported environment variables are different from version + to version. Refer to PostgreSQL Programmer's Manual (libpq - + Environment Variables) for details. + + + From PostgreSQL 7.1.0, text data type has 1GB as its max + size. Older PostgreSQL's text data type is limitted by block + size. (Default 8KB. Max 32KB defined at compile time) + + + To use the large object (lo) interface, it is required to enclose + large object functions within a transaction block. A transaction + block starts with a SQL statement begin and if + the transaction was valid ends with commit or + end. If the transaction fails the transaction + should be closed with rollback or + abort. Using Large Objects ]]> + Do not close connection resource before closing large object + resource.
@@ -121,26 +168,32 @@ - Returns &false; if connection is not a valid connection resource, &true; - otherwise. Closes down the connection to a PostgreSQL database - associated with the given connection resource. + pg_close closes down the non-persistent + connection to a PostgreSQL database associated with the given + connection resource. It returns &true;, if + connection is a valid connection resource, + otherwise it return &false;. + + + + pg_close is not usually necessary, as + non-persistent open links are automatically closed at the end of + the script's execution. pg_close will not + close persistent links generated by + pg_pconnect. + + + + If there is open large object resource on the connection, do not + close the connection before closing all large object resources. - - This isn't usually necessary, as non-persistent open - links are automatically closed at the end of the script's - execution. - - - pg_close will not close persistent links - generated by pg_pconnect. - pg_cmdtuples - Returns number of affected tuples + Returns number of affected records(tuples) Description @@ -152,8 +205,9 @@ pg_cmdtuples returns the number of tuples - (instances) affected by INSERT, UPDATE, and DELETE queries. If no - tuple is affected the function will return 0. + (instances/records/rows) affected by INSERT, UPDATE, and DELETE + queries executed by pg_exec. If no tuple is + affected by this function, it will return 0. <function>pg_cmdtuples</function> @@ -161,14 +215,14 @@ ]]> - See also pg_numfields and + See also pg_exec and pg_numrows. @@ -184,74 +238,64 @@ echo $cmdtuples . " cmdtuples affected."; resource pg_connect - string host - string port - string dbname - - - resource pg_connect - string host - string port - string options - string dbname - - - resource pg_connect - string host - string port - string options - string tty - string dbname - - - resource pg_connect - string conn_string + string connection_string - Returns a connection resource on success, or &false; if the - connection could not be made. Opens a connection to a PostgreSQL - database. The arguments should be within a quoted string. + pg_connect returns a connection resource + that is needed by other PostgreSQL functions. + + + pg_connect opens a connection to a + PostgreSQL database specified by + connection_string. It returns a connection + resource on success. It returns &false;, if the connection could + not be made. connection_string should be + a quoted string. - Using pg_connect arguments + Using pg_connect ]]> - The arguments available include host, - port, tty, - options, dbname, - user, and password. + The arguments available for + connection_string includes + host, port, + tty, options, + dbname, user, and + password. If a second call is made to pg_connect with - the same arguments, no new connection will be established, but - instead, the connection resource of the already opened connection - will be returned. + the same connection_string arguments, 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 patameters. (i.e. Use different username) - This function returns a connection resource that is needed by other - PostgreSQL functions. You can have multiple connections open at - once. - - - The previous syntax of: - $conn = pg_connect ("host", "port", "options", "tty", - "dbname") + Syntax supports multiple parameters: + $conn = pg_connect ("host", "port", "options", "tty", "dbname") has been deprecated. - See also pg_pconnect. + See also pg_pconnect, + pg_close, pg_host, + pg_port, pg_tty, + pg_options and pg_dbname. @@ -270,9 +314,10 @@ $dbconn3 = pg_Connect ("host=sheep port=5432 dbname=mary user=lamb password=baaa - Returns the name of the database that the given PostgreSQL - connection resource is connected to, or &false; if connection is not a - valid connection resource. + pg_dbname returns the name of the database + that the given PostgreSQL connection + resource. It retuns &false;, if connection + is not a valid PostgreSQL connection resource. @@ -293,10 +338,13 @@ $dbconn3 = pg_Connect ("host=sheep port=5432 dbname=mary user=lamb password=baaa - pg_end_copy syncs PostgreSQL frontend with - the backend after doing a copy operation. It must be issued or - the backend may get "out of sync" with the frontend. Returns - &true; if successfull, &false; otherwise. + pg_end_copy syncs PostgreSQL frontend + (usually a web server process) with the PostgreSQL server after + doing a copy operation performed by + pg_put_line. pg_end_copy + must be issued, otherwise the PostgreSQL server may get "out of + sync" error with the frontend. It returns &true; for success, + otherwise it returns &false;. For further details and an example, see also @@ -308,7 +356,7 @@ $dbconn3 = pg_Connect ("host=sheep port=5432 dbname=mary user=lamb password=baaa pg_errormessage - Get the error message string + Get the last error message string of a connection Description @@ -319,12 +367,19 @@ $dbconn3 = pg_Connect ("host=sheep port=5432 dbname=mary user=lamb password=baaa - Returns a string containing the error message, &false; on failure. - Details about the error probably cannot be retrieved using the - pg_errormessage function if an error occured - on the last database action for which a valid connection exists, - this function will return a string containing the error message - generated by the backend server. + pg_errormessage returns a string containing + the last error message for given + connection. It returns &false; on failure. + + + pg_errormessage returns the last error + message for given connection and error + message may be overwritten if other libpq functions are called on + the connection. PostgreSQL functions calls libpq functions + internally. Therefore, details about the error may not be + retrieved using the pg_errormessage + function. pg_result_error_message() will be added from 4.2.0 to + get last error for the result resource. @@ -339,20 +394,25 @@ $dbconn3 = pg_Connect ("host=sheep port=5432 dbname=mary user=lamb password=baaa resource pg_exec - resourceconnection + resource connection string query - Returns a query result resource if query could be executed, - &false; on failure or if connection is not a valid connection - index. Details about the error can be retrieved using the - pg_ErrorMessage function if connection is - valid. Sends an SQL statement to the PostgreSQL database - specified by the connection index. The connection must be a valid - index that was returned by pg_Connect. The - return value of this function is an index to be used to access - the results from other PostgreSQL functions. + pg_exec returns a query result resource if + query could be executed. It returns &false; on failure or if + connection is not a valid connection. Details about the error can + be retrieved using the pg_errormessage + function if connection is valid. + pg_errormessage sends an SQL statement to + the PostgreSQL database specified by the + connection resource. The + connection must be a valid connection that + was returned by pg_connect or + pg_pconnect. The return value of this + function is an query result resource to be used to access the + results from other PostgreSQL functions such as + pg_fetch_array. PHP/FI returned 1 if the query was not expected to return data @@ -362,6 +422,13 @@ $dbconn3 = pg_Connect ("host=sheep port=5432 dbname=mary user=lamb password=baaa + + See also pg_fetch_array, + pg_fetch_object, + pg_result, pg_numrows, + pg_cmdtuples and + pg_numfields. + @@ -382,40 +449,52 @@ $dbconn3 = pg_Connect ("host=sheep port=5432 dbname=mary user=lamb password=baaa - - Returns: An array that corresponds to the fetched row, or &false; - if there are no more rows. + + pg_fetch_array returns an array that + corresponds to the fetched row (tuples/records). It returns + &false;, if there are no more rows. pg_fetch_array is an extended version of pg_fetch_row. In addition to storing the - data in the numeric indices of the result array, it also stores - the data in associative indices, using the field names as keys. + data in the numeric indices (field index) to the result array, it + also stores the data in associative indices (field name) by + default. - The third optional argument result_type in - pg_fetch_array is a constant and can take the + row is row (record) number to be + retrived. First row is 0. + + + result_type is optional parameter controls + how return value is initilized. + result_type is a constant and can take the following values: PGSQL_ASSOC, PGSQL_NUM, and PGSQL_BOTH. + pg_fetch_array returns associative array + that has field name as key for PGSQL_ASSOC. field index as key + with PGSQL_NUM and both field name/index as key with + PGSQL_BOTH. Default is PGSQL_BOTH. - Result_type was added in PHP 4.0. + result_type was added in PHP 4.0. - An important thing to note is that using pg_fetch_array is NOT significantly slower than using pg_fetch_row, while it - provides a significant added value. + provides a significant ease of use. - For further details, see also - pg_fetch_row + See also pg_fetch_row and + pg_fetch_object and + pg_result. - - PostgreSQL fetch array - - + + PostgreSQL fetch array + + ]]> - - + + + @@ -458,9 +538,10 @@ echo $arr["author"] . " <- array\n"; - - Returns: An object with properties that correspond to the fetched - row, or &false; if there are no more rows. + + pg_fetch_object returns an object with + properties that correspond to the fetched row. It returns &false; + if there are no more rows or error. pg_fetch_object is similar to @@ -470,12 +551,19 @@ echo $arr["author"] . " <- array\n"; their offsets (numbers are illegal property names). - The third optional argument result_type in - pg_fetch_object is a constant and can take the + result_type is optional parameter controls + how return value is initilized. + result_type is a constant and can take the following values: PGSQL_ASSOC, PGSQL_NUM, and PGSQL_BOTH. + pg_fetch_array returns associative array + that has field name as key for PGSQL_ASSOC. field index as key + with PGSQL_NUM and both field name/index as key with + PGSQL_BOTH. Default is PGSQL_BOTH. + + - Result_type was added in PHP 4.0. + result_type was added in PHP 4.0. @@ -486,8 +574,10 @@ echo $arr["author"] . " <- array\n"; insignificant). - See also: pg_fetch_array and - pg_fetch_row. + See also pg_exec, pg_fetch_array, + pg_fetch_row and pg_result. + + Postgres fetch object @@ -526,7 +616,7 @@ while ($data = pg_fetch_object ($qu, $row)): endwhile; echo "----------\n"; ?> ]]> @@ -550,20 +640,24 @@ pg_close ($db_conn); int row + + pg_fetch_row fetches one row of data from + the result associated with the specified + result resource. The row (record) is + returned as an array. Each result column is stored in an array + offset, starting at offset 0. + - Returns: An array that corresponds to the fetched row, or &false; + It returns an array that corresponds to the fetched row, or &false; if there are no more rows. - pg_fetch_row fetches one row of data from - the result associated with the specified result identifier. The - row is returned as an array. Each result column is stored in an - array offset, starting at offset 0. + See also: pg_exec, + pg_fetch_array, + pg_fetch_object and + pg_result. - See also: pg_fetch_array, - pg_fetch_object, - pg_result. Postgres fetch row @@ -618,9 +712,10 @@ for ($i=0; $i < $num; $i++) { - Test if a field is &null; or not. Returns 0 if the field in the - given row is not &null;. Returns 1 if the field in the given row is - &null;. Field can be specified as number or fieldname. Row + pg_fieldisnull test if a field is &null; or + not. It returns 1 if the field in the given row is &null;. It + returns 0 if the field in the given row is NOT &null;. Field can + be specified as colum index (number) or fieldname (string). Row numbering starts at 0. @@ -641,9 +736,13 @@ for ($i=0; $i < $num; $i++) { - pg_fieldname will return the name of the - field occupying the given column number in the given PostgreSQL - result identifier. Field numbering starts from 0. + pg_fieldname returns the name of the field + occupying the given field_number in the + given PostgreSQL result resource. Field + numbering starts from 0. + + + See also pg_filednum. @@ -664,9 +763,13 @@ for ($i=0; $i < $num; $i++) { pg_fieldnum will return the number of the - column slot that corresponds to the named field in the given - PosgreSQL result identifier. Field numbering starts at 0. This - function will return -1 on error. + column (field) slot that corresponds to the + field_name in the given PosgreSQL + result resource. Field numbering starts + at 0. This function will return -1 on error. + + + See also pg_fieldname. @@ -687,10 +790,13 @@ for ($i=0; $i < $num; $i++) { - pg_fieldprtlen will return the actual - printed length (number of characters) of a specific value in a - PostgreSQL result. Row numbering starts at 0. This function - will return -1 on an error. + pg_fieldprtlen returns the actual printed + length (number of characters) of a specific value in a PostgreSQL + result. Row numbering starts at 0. This + function will return -1 on an error. + + + See also pg_fieldsize. @@ -712,11 +818,14 @@ for ($i=0; $i < $num; $i++) { - pg_fieldsize will return the internal - storage size (in bytes) of the field number in the given - PostgreSQL result. Field numbering starts at 0. A field size of - -1 indicates a variable length field. This function will return - &false; on error. + pg_fieldsize returns the internal storage + size (in bytes) of the field number in the given PostgreSQL + result. Field numbering starts at 0. A + field size of -1 indicates a variable length field. This function + will return &false; on error. + + + See also pg_fieldlen and pg_fieldtype. @@ -738,9 +847,13 @@ for ($i=0; $i < $num; $i++) { - pg_fieldtype will return a string containing - the type name of the given field in the given PostgreSQL result - identifier. Field numbering starts at 0. + pg_fieldtype returns a string containing the + type name of the given field_number in the + given PostgreSQL result resource. Field + numbering starts at 0. + + + See also pg_fieldlen and pg_fieldname. @@ -764,8 +877,12 @@ for ($i=0; $i < $num; $i++) { running. All result memory will automatically be freed when the script is finished. But, if you are sure you are not going to need the result data anymore in a script, you may call - pg_freeresult with the result identifier as - an argument and the associated result memory will be freed. + pg_freeresult with the + result resource as an argument and the + associated result memory will be freed. + + + See also pg_exec. @@ -773,7 +890,7 @@ for ($i=0; $i < $num; $i++) { pg_getlastoid - Returns the last object identifier + Returns the last object's oid Description @@ -784,13 +901,17 @@ for ($i=0; $i < $num; $i++) { - pg_getlastoid can be used to retrieve the - oid assigned to an inserted tuple if the result - identifier is used from the last command sent via - pg_exec and was an SQL INSERT. Returns a positive - integer if there was a valid oid. It returns &false; - if an error occurs or the last command sent via - pg_exec was not an INSERT. + pg_getlastoid is used to retrieve the + oid assigned to an inserted tuple (record) if + the result resource is used from the last command sent via + pg_exec and was an SQL INSERT. Returns a + positive integer if there was a valid oid. It + returns &false; if an error occurs or the last command sent via + pg_exec was not an INSERT or INSERT is + failed. + + + See also pg_exec. @@ -811,8 +932,53 @@ for ($i=0; $i < $num; $i++) { - pg_host will return the host name of the - given PostgreSQL connection identifier is connected to. + pg_host returns the host name of the given + PostgreSQL connection resource is + connected to. + + + See also pg_connect and + pg_pconnect. + + + + + + + pg_last_notice + + Returns the last notice message from PostgreSQL server + + + + Description + + + string pg_last_notice + resource connection + + + + pg_last_notice returns the last notice + message from PostgreSQL server specified by + connection. PostgreSQL server set notice + message when transaction cannot be continued. There one can avoid + issuing useless SQL using pg_exec using + pg_last_notice. There are other cases that + PostgreSQL server sets notice message. Programmer must check + contents of notice message if it is related to transaction or + not. + + + + pg_last_notice is added form PHP + 4.0.6. However, PHP 4.0.6 has problem with notice message + handling. Use of PostgreSQL module with PHP 4.0.6 is not recommended + even if you are not using pg_last_notice. + + + + See also pg_exec and pg_errormessage. @@ -835,6 +1001,15 @@ for ($i=0; $i < $num; $i++) { Object. large_object is a resource for the large object from pg_loopen. + + To use the large object (lo) interface, it is necessary to + enclose it within a transaction block. + + + See also pg_loopen, + pg_locreate and + pg_loimport. + @@ -854,11 +1029,19 @@ for ($i=0; $i < $num; $i++) { pg_locreate creates an Inversion Large Object and returns the oid of the large - object. connection specifies a valid database - connection. PostgreSQL access modes INV_READ, INV_WRITE, and - INV_ARCHIVE are not supported, the object is created always with - both read and write access. INV_ARCHIVE has been removed from - PostgreSQL itself (version 6.3 and above). + object. connection specifies a valid + database connection opened by pg_connect or + pg_pconnect. PostgreSQL access modes + INV_READ, INV_WRITE, and INV_ARCHIVE are not supported, the + object is created always with both read and write + access. INV_ARCHIVE has been removed from PostgreSQL itself + (version 6.3 and above). It returns large object oid + otherwise. It retuns &false;, if an error occurred, + + + + To use the large object (lo) interface, it is necessary to + enclose it within a transaction block. @@ -877,7 +1060,7 @@ for ($i=0; $i < $num; $i++) { oid string - filename + pathname resource connection @@ -885,12 +1068,17 @@ for ($i=0; $i < $num; $i++) { - The oid argument specifies the object id - of the large object to export and the - filename argument specifies the pathname - of the file. Returns &false; if an error occurred, &true; - otherwise. Remember that handling large objects in PostgreSQL - must happen inside a transaction. + The oid argument specifies oid of the + large object to export and the pathname + argument specifies the pathname of the file. It returns &false; if + an error occurred, &true; otherwise. + + + To use the large object (lo) interface, it is necessary to + enclose it within a transaction block. + + + See also pg_loimport. @@ -905,22 +1093,27 @@ for ($i=0; $i < $num; $i++) { int pg_loimport - string - filename - - int - connection_id + string pathname + resource + connection - The filename argument specifies the - pathname of the file to be imported as a large object. Returns - &false; if an error occurred, object id of the just created large - object otherwise. Remember that handling large objects in - PostgreSQL must happen inside a transaction. + The pathname argument specifies the + pathname of the file to be imported as a large object. It returns + &false; if an error occurred, oid of the just created large + object otherwise. + + + To use the large object (lo) interface, it is necessary to + enclose it within a transaction block. + + ¬e.sm.uidcheck; + + See also pg_loexport and + pg_loopen. - ¬e.sm.uidcheck; @@ -933,20 +1126,33 @@ for ($i=0; $i < $num; $i++) { Description - bool pg_loopen + resource pg_loopen resource connection - int objoid + int oid string mode pg_loopen open an Inversion Large Object and - returns file descriptor of the large object. The file descriptor - encapsulates information about the connection. Do not close the - connection before closing the large object file descriptor. - objoid specifies a valid large object oid - and mode can be either "r", "w", or - "rw". It returns &false; if there is error. + returns large object resource. The resource encapsulates + information about the connection. + oid specifies a valid large object oid and + mode can be either "r", "w", or "rw". It + returns &false; if there is an error. + + + + Do not close the database connection before closing the large + object resource. + + + + To use the large object (lo) interface, it is necessary to + enclose it within a transaction block. + + + See also pg_loclose and + pg_locreate. @@ -970,7 +1176,15 @@ for ($i=0; $i < $num; $i++) { len bytes from a large object and returns it as a string. large_object specifies a valid large object resource andlen - specifies the maximum allowable size of the large object segment. + specifies the maximum allowable size of the large object + segment. It returns &false; if there is an error. + + + To use the large object (lo) interface, it is necessary to + enclose it within a transaction block. + + + See also pg_loreadall. @@ -986,14 +1200,23 @@ for ($i=0; $i < $num; $i++) { Description - void pg_loreadall + int pg_loreadall resource large_object - pg_loreadall reads a large object and - passes it straight through to the browser after sending all pending - headers. Mainly intended for sending binary data like images or sound. + pg_loreadall reads a large object and passes + it straight through to the browser after sending all pending + headers. Mainly intended for sending binary data like images or + sound. It returns number of bytes read. It returns &false;, if an + error occured. + + + To use the large object (lo) interface, it is necessary to + enclose it within a transaction block. + + + See also pg_loread. @@ -1007,14 +1230,23 @@ for ($i=0; $i < $num; $i++) { Description - void pg_lounlink + bool pg_lounlink resource connection - resource large_object + int oid pg_lounlink deletes a large object with the - large_object identifier for that large object. + oid. It rreturn &true; on success, + otherwise returns &false;. + + + To use the large object (lo) interface, it is necessary to + enclose it within a transaction block. + + + See also pg_locreate and + pg_loimport. @@ -1030,16 +1262,23 @@ for ($i=0; $i < $num; $i++) { int pg_lowrite resource large_object - string buf + string data pg_lowrite writes at most to a large object - from a variable buf and returns the number + from a variable data and returns the number of bytes actually written, or &false; in the case of an error. large_object is a large object resource - from pg_loopen. It returns &false; if there - is error. + from pg_loopen. + + + To use the large object (lo) interface, it is necessary to + enclose it within a transaction block. + + + See also pg_locreate and + pg_loopen. @@ -1058,10 +1297,11 @@ for ($i=0; $i < $num; $i++) { - pg_numfields will return the number of - fields (columns) in a PostgreSQL result. The argument is a valid - result identifier returned by pg_exec. This - function will return -1 on error. + pg_numfields returns the number of fields + (columns) in a PostgreSQL result. The + argument is a result resource returned by + pg_exec. This function will return -1 on + error. See also pg_numrows and @@ -1085,7 +1325,7 @@ for ($i=0; $i < $num; $i++) { pg_numrows will return the number of rows in a - PostgreSQL result. The argument is a valid result identifier + PostgreSQL result. The argument is a result resource returned by pg_exec. This function will return -1 on error. @@ -1111,8 +1351,8 @@ for ($i=0; $i < $num; $i++) { pg_options will return a string containing - the options specified on the given PostgreSQL connection - identifier. + the options specified on the given PostgreSQL + connection resource. @@ -1127,22 +1367,48 @@ for ($i=0; $i < $num; $i++) { int pg_pconnect - string conn_string + string connection_string - Returns a connection resource on success, or &false; if the - connection could not be made. Opens a connection to a PostgreSQL - database. The arguments should be within a quoted string. The - arguments available include host, - port, tty, - options, dbname, - user, and password. + pg_pconnect opens a connection to a + PostgreSQL database. It returns a connection resource that is + needed by other PostgreSQL functions. - This function returns a connection resource that is needed by - other PostgreSQL functions. You can have multiple connections - open at once. + It returns a connection resource on success, or &false; if the + connection could not be made. The arguments should be within a + quoted string. The arguments available include + host, port, + tty, options, + dbname, user, and + password. + + + Using pg_connect + + +]]> + + + + If a second call is made to pg_pconnect with + the same arguments, 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 patameters. (i.e. Use + different username) The previous syntax of: @@ -1151,6 +1417,21 @@ for ($i=0; $i < $num; $i++) { has been deprecated. + + To enable persistent connection, pgsql.allow_persistent + php.ini directive must be set to "On". (Default is On) + Max number of persistent connection can be defined by pgsql.max_persistent + php.ini directive. (Default is -1 which is no limit) Total number + of connection can be set by pgsql.max_links php.ini + directive. + + + pg_close will not close persistent links + generated by pg_pconnect. + See also pg_connect. @@ -1173,8 +1454,9 @@ for ($i=0; $i < $num; $i++) { - pg_port will return the port number that the - given PostgreSQL connection resource is connected to. + pg_port returns the port number that the + given PostgreSQL connection resource is + connected to. @@ -1200,7 +1482,7 @@ for ($i=0; $i < $num; $i++) { to the PostgreSQL backend server. This is useful for example for very high-speed inserting of data into a table, initiated by starting a PostgreSQL copy-operation. That final NULL-character - is added automatically. Returns &true; if successfull, &false; + is added automatically. It returns &true; if successfull, &false; otherwise. @@ -1235,7 +1517,7 @@ for ($i=0; $i < $num; $i++) { pg_result - Returns values from a result identifier + Returns values from a result resource Description @@ -1244,14 +1526,16 @@ for ($i=0; $i < $num; $i++) { mixed pg_result resource result int row_number - mixed fieldname + mixed field - pg_result will return values from a result - identifier produced by pg_Exec. The - row_number and - fieldname sepcify what cell in the table + pg_result returns values from a + result resource returned by + pg_exec. row_number + is integer. field is field name(string) + or field index (integer). The row_number + and field sepcify what cell in the table of results to return. Row numbering starts from 0. Instead of naming the field, you may use the field index as an unquoted number. Field indices start from 0. @@ -1259,15 +1543,18 @@ for ($i=0; $i < $num; $i++) { PostgreSQL has many built in types and only the basic ones are directly supported here. All forms of integer, - boolean and void - - types are returned as integer values. All forms of float, - and - real types are returned as float values. All other types, - including arrays are returned as strings formatted in the same - default PostgreSQL manner that you would see in the - psql program. - + boolean and void + + + types are + returned as integer values. All forms of float, and + real types are returned as float values. All other + types, including arrays are returned as strings formatted in the + same default PostgreSQL manner that you would see in the + psql program. + @@ -1290,8 +1577,8 @@ for ($i=0; $i < $num; $i++) { - The function set the client encoding and return 0 if success or - -1 if error. + pg_set_client_encoding sets the client + encoding and return 0 if success or -1 if error. encoding is the client @@ -1303,7 +1590,10 @@ for ($i=0; $i < $num; $i++) { This function requires PHP-4.0.2 or higher and PostgreSQL-7.0 or - higher. + higher. If libpq is compiled without multibyte encoding support, + pg_set_client_encoding will not be + included. Refer to PostgreSQL manual to enable multibyte support + for PostgreSQL server and libpq. The function used to be called @@ -1334,11 +1624,11 @@ for ($i=0; $i < $num; $i++) { - The functions returns the client encoding as the string. The - returned string should be either : + pg_client_encoding returns the client + encoding as the string. The returned string should be either : SQL_ASCII, EUC_JP, EUC_CN, EUC_KR, EUC_TW, UNICODE, - MULE_INTERNAL, LATINX (X=1...9), KOI8, WIN, ALT, - SJIS, BIG5, WIN1250. + MULE_INTERNAL, LATINX (X=1...9), KOI8, WIN, ALT, SJIS, BIG5, + WIN1250. @@ -1367,7 +1657,7 @@ for ($i=0; $i < $num; $i++) { bool pg_trace string - filename + pathname string mode @@ -1378,13 +1668,16 @@ for ($i=0; $i < $num; $i++) { - Enables tracing of the PostgreSQL frontend/backend communication - to a debugging file. To fully understand the results one needs to - be familiar with the internals of PostgreSQL communication - protocol. For those who are not, it can still be useful for - tracing errors in queries sent to the server, you could do for - example grep '^To backend' trace.log and see - what query actually were sent to the PostgreSQL server. + pg_trace enables tracing of the PostgreSQL + frontend/backend communication to a debugging file specified as + pathname. To fully understand the results, + one needs to be familiar with the internals of PostgreSQL + communication protocol. For those who are not, it can still be + useful for tracing errors in queries sent to the server, you + could do for example grep '^To backend' + trace.log and see what query actually were sent to the + PostgreSQL server. For more information, refer to PostgreSQL + manual. Filename and mode @@ -1394,7 +1687,7 @@ for ($i=0; $i < $num; $i++) { trace and defaults to the last one opened. - Returns &true; if filename could be opened + It returns &true; if pathname could be opened for logging, &false; otherwise. @@ -1420,9 +1713,9 @@ for ($i=0; $i < $num; $i++) { - pg_tty will return the tty name that server + pg_tty returns the tty name that server side debugging output is sent to on the given PostgreSQL - connection resource. + connection resource.