diff --git a/reference/pgsql/functions/pg-affected-rows.xml b/reference/pgsql/functions/pg-affected-rows.xml index fc6a3d159a..6b59e3f3fc 100644 --- a/reference/pgsql/functions/pg-affected-rows.xml +++ b/reference/pgsql/functions/pg-affected-rows.xml @@ -1,48 +1,48 @@ - + - - - pg_affected_rows - Returns number of affected records (tuples) - - - Description - - intpg_affected_rows - resourceresult - - - pg_affected_rows returns the number of tuples - (instances/records/rows) affected by INSERT, UPDATE, and DELETE - queries executed by pg_query. If no tuple is - affected by this function, it will return 0. - - - - <function>pg_affected_rows</function> example - + + + pg_affected_rows + Returns number of affected records (tuples) + + + Description + + intpg_affected_rows + resourceresult + + + pg_affected_rows returns the number of tuples + (instances/records/rows) affected by INSERT, UPDATE, and DELETE + queries executed by pg_query. If no tuple is + affected by this function, it will return 0. + + + + <function>pg_affected_rows</function> example + ]]> - - - - - - This function used to be called pg_cmdtuples(). - - - - See also pg_query and - pg_num_rows. - - - + + + + + + This function used to be called pg_cmdtuples(). + + + + See also pg_query and + pg_num_rows. + + + + - - - pg_cancel_query - - Cancel asynchronous query - - - - Description - - boolpg_cancel_query - resourceconnection - - - pg_cancel_query cancel asynchronous query sent by - pg_send_query. You cannot cancel query executed by - pg_query. - - - See also pg_send_query and - pg_connection_busy. - - - + + + pg_cancel_query + + Cancel asynchronous query + + + + Description + + boolpg_cancel_query + resourceconnection + + + pg_cancel_query cancel asynchronous query sent by + pg_send_query. You cannot cancel query executed by + pg_query. + + + See also pg_send_query and + pg_connection_busy. + + + + - - - pg_client_encoding - - Gets the client encoding - - - - Description - - stringpg_client_encoding - resourceconnection - - - 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. - - - - This function requires PHP-4.0.3 or higher and PostgreSQL-7.0 or - higher. If libpq is compiled without multibyte encoding support, - pg_set_client_encoding always return - "SQL_ASCII". Supported encoding depends on PostgreSQL - version. Refer to PostgreSQL manual for details to enable - multibyte support and encoding supported. - - - The function used to be called pg_clientencoding. - - - - See also pg_set_client_encoding. - - - + + + pg_client_encoding + + Gets the client encoding + + + + Description + + stringpg_client_encoding + resourceconnection + + + 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. + + + + This function requires PHP-4.0.3 or higher and PostgreSQL-7.0 or + higher. If libpq is compiled without multibyte encoding support, + pg_set_client_encoding always return + "SQL_ASCII". Supported encoding depends on PostgreSQL + version. Refer to PostgreSQL manual for details to enable + multibyte support and encoding supported. + + + The function used to be called pg_clientencoding. + + + + See also pg_set_client_encoding. + + + + - - - pg_close - Closes a PostgreSQL connection - - - Description - - boolpg_close - resourceconnection - - - pg_close closes the non-persistent - connection to a PostgreSQL database associated with the given - connection resource. &return.success; - - - - Using pg_close is not usually necessary, as - non-persistent open connections are automatically closed at the end - of the script. - - - - - <function>pg_close</function> example - + + + pg_close + Closes a PostgreSQL connection + + + Description + + boolpg_close + resourceconnection + + + pg_close closes the non-persistent + connection to a PostgreSQL database associated with the given + connection resource. &return.success; + + + + Using pg_close is not usually necessary, as + non-persistent open connections are automatically closed at the end + of the script. + + + + + <function>pg_close</function> example + ]]> - - - - - If there is open large object resource on the connection, do not - close the connection before closing all large object resources. - - - + + + + + If there is open large object resource on the connection, do not + close the connection before closing all large object resources. + + + + - - - pg_connect - Open a PostgreSQL connection - - - Description - - resourcepg_connect - stringconnection_string - intconnect_type - - - pg_connect returns a connection resource - that is needed by other PostgreSQL functions. - - - pg_connect opens a connection to a - PostgreSQL database specified by the - 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 <function>pg_connect</function> - + + + pg_connect + Open a PostgreSQL connection + + + Description + + resourcepg_connect + stringconnection_string + intconnect_type + + + pg_connect returns a connection resource + that is needed by other PostgreSQL functions. + + + pg_connect opens a connection to a + PostgreSQL database specified by the + 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 <function>pg_connect</function> + ]]> - - - 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 connection_string, no - new connection will be established unless you pass - PGSQL_CONNECT_FORCE_NEW as - connect_type, 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 strings. - - - The old syntax with multiple parameters - $conn = pg_connect("host", "port", "options", "tty", "dbname") - has been deprecated. - - - See also pg_pconnect, - pg_close, pg_host, - pg_port, pg_tty, - pg_options and pg_dbname. - - - + + + 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 connection_string, no + new connection will be established unless you pass + PGSQL_CONNECT_FORCE_NEW as + connect_type, 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 strings. + + + The old syntax with multiple parameters + $conn = pg_connect("host", "port", "options", "tty", "dbname") + has been deprecated. + + + See also pg_pconnect, + pg_close, pg_host, + pg_port, pg_tty, + pg_options and pg_dbname. + + + + - - - pg_connection_busy - - Get connection is busy or not - - - - Description - - boolpg_connection_busy - resourceconnection - - - pg_connection_busy returns &true; if the - connection is busy. If it is busy, a previous query is still executing. - If pg_get_result is called, it will be blocked. - - - - <function>pg_connection_busy</function> example - + + + pg_connection_busy + + Get connection is busy or not + + + + Description + + boolpg_connection_busy + resourceconnection + + + pg_connection_busy returns &true; if the + connection is busy. If it is busy, a previous query is still executing. + If pg_get_result is called, it will be blocked. + + + + <function>pg_connection_busy</function> example + ]]> - - - - - See also pg_connection_status and - pg_get_result. - - - + + + + + See also pg_connection_status and + pg_get_result. + + + + - - - pg_connection_reset - - Reset connection (reconnect) - - - - Description - - boolpg_connection_reset - resourceconnection - - - pg_connection_reset resets the connection. - It is useful for error recovery. &return.success; - - - - <function>pg_connection_reset</function> example - + + + pg_connection_reset + + Reset connection (reconnect) + + + + Description + + boolpg_connection_reset + resourceconnection + + + pg_connection_reset resets the connection. + It is useful for error recovery. &return.success; + + + + <function>pg_connection_reset</function> example + ]]> - - - - - See also pg_connect, - pg_pconnect and - pg_connection_status. - - - + + + + + See also pg_connect, + pg_pconnect and + pg_connection_status. + + + + - - - pg_connection_status - - Get connection status - - - - Description - - intpg_connection_status - resourceconnection - - - pg_connection_status returns a connection status. - Possible statuses are PGSQL_CONNECTION_OK and - PGSQL_CONNECTION_BAD. The return value 0 as - integer indicates a valid connection. - - - - <function>pg_connection_status</function> example - + + + pg_connection_status + + Get connection status + + + + Description + + intpg_connection_status + resourceconnection + + + pg_connection_status returns a connection status. + Possible statuses are PGSQL_CONNECTION_OK and + PGSQL_CONNECTION_BAD. The return value 0 as + integer indicates a valid connection. + + + + <function>pg_connection_status</function> example + ]]> - - - - - See also pg_connection_busy. - - - + + + + + See also pg_connection_busy. + + + + - - - pg_convert - - Convert associative array value into suitable for SQL statement - - - - Description - - arraypg_convert - resourceconnection - stringtable_name - arrayassoc_array - intoptions - - - pg_convert checks and converts the values in - assoc_array into suitable values for use in a SQL - statement. Precondition for pg_convert is the existence - of a table table_name which has at least as many columns - as assoc_array has elements. The fieldnames as well as - the fieldvalues in table_name must match the indices and - values of assoc_array. Returns an array with the converted - values on success, &false; otherwise. - - &warn.experimental.func; - - See also pg_meta_data. - - - + + + pg_convert + + Convert associative array value into suitable for SQL statement + + + + Description + + arraypg_convert + resourceconnection + stringtable_name + arrayassoc_array + intoptions + + + pg_convert checks and converts the values in + assoc_array into suitable values for use in a SQL + statement. Precondition for pg_convert is the existence + of a table table_name which has at least as many columns + as assoc_array has elements. The fieldnames as well as + the fieldvalues in table_name must match the indices and + values of assoc_array. Returns an array with the converted + values on success, &false; otherwise. + + &warn.experimental.func; + + See also pg_meta_data. + + + + - - - pg_copy_from - - Insert records into a table from an array - - - - Description - - boolpg_copy_from - resourceconnection - stringtable_name - arrayrows - stringdelimiter - stringnull_as - - - pg_copy_from insert records into a table from - rows. It issues COPY FROM SQL command - internally to insert records. - &return.success; - - - See also pg_copy_to. - - - + + + pg_copy_from + + Insert records into a table from an array + + + + Description + + boolpg_copy_from + resourceconnection + stringtable_name + arrayrows + stringdelimiter + stringnull_as + + + pg_copy_from insert records into a table from + rows. It issues COPY FROM SQL command + internally to insert records. + &return.success; + + + See also pg_copy_to. + + + + - - - pg_copy_to - - Copy a table to an array - - - - Description - - arraypg_copy_to - resourceconnection - stringtable_name - stringdelimiter - stringnull_as - - - pg_copy_to copies a table to an array. It - issues COPY TO SQL command internally to - retrieve records. The resulting array is returned. It returns - &false; on failure. - - - See also pg_copy_from. - - - + + + pg_copy_to + + Copy a table to an array + + + + Description + + arraypg_copy_to + resourceconnection + stringtable_name + stringdelimiter + stringnull_as + + + pg_copy_to copies a table to an array. It + issues COPY TO SQL command internally to + retrieve records. The resulting array is returned. It returns + &false; on failure. + + + See also pg_copy_from. + + + + - - - pg_dbname - Get the database name - - - Description - - stringpg_dbname - resourceconnection - - - pg_dbname returns the name of the database - that the given PostgreSQL connection - resource. It returns &false;, if connection - is not a valid PostgreSQL connection resource. - - - - <function>pg_dbname</function> example - + + + pg_dbname + Get the database name + + + Description + + stringpg_dbname + resourceconnection + + + pg_dbname returns the name of the database + that the given PostgreSQL connection + resource. It returns &false;, if connection + is not a valid PostgreSQL connection resource. + + + + <function>pg_dbname</function> example + ]]> - - - - - + + + + + + - - - pg_delete - - Deletes records - - - - Description - - mixedpg_delete - resourceconnection - stringtable_name - arrayassoc_array - intoptions - - - pg_delete deletes record condition specified by - assoc_array which has - field=>value. If option is - specified, pg_convert is applied - to assoc_array with specified option. - - - - <function>pg_delete</function> example - + + + pg_delete + + Deletes records + + + + Description + + mixedpg_delete + resourceconnection + stringtable_name + arrayassoc_array + intoptions + + + pg_delete deletes record condition specified by + assoc_array which has + field=>value. If option is + specified, pg_convert is applied + to assoc_array with specified option. + + + + <function>pg_delete</function> example + ]]> - - - - &warn.experimental.func; - - See also pg_convert. - - - + + + + &warn.experimental.func; + + See also pg_convert. + + + + - - - pg_end_copy - Sync with PostgreSQL backend - - - Description - - boolpg_end_copy - resourceconnection - - - pg_end_copy syncs the 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 with the frontend and will report an error. &return.success; - - - For further details and an example, see also - pg_put_line. - - - + + + pg_end_copy + Sync with PostgreSQL backend + + + Description + + boolpg_end_copy + resourceconnection + + + pg_end_copy syncs the 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 with the frontend and will report an error. &return.success; + + + For further details and an example, see also + pg_put_line. + + + + - - - pg_escape_bytea - - Escape binary for bytea type - - - - Description - - stringpg_escape_bytea - stringdata - - - pg_escape_bytea escapes string for - bytea datatype. It returns escaped string. - - - - When you SELECT bytea type, PostgreSQL returns octal byte value - prefixed by \ (e.g. \032). Users are supposed to convert back to - binary format by yourself. - - - This function requires PostgreSQL 7.2 or later. With PostgreSQL - 7.2.0 and 7.2.1, bytea type must be casted when you enable - multi-byte support. i.e. INSERT INTO test_table (image) - VALUES ('$image_escaped'::bytea); PostgreSQL 7.2.2 or - later does not need cast. Exception is when client and backend - character encoding does not match, there may be multi-byte - stream error. User must cast to bytea to avoid this error. - - - - See also pg_unescape_bytea and - pg_escape_string. - - - + + + pg_escape_bytea + + Escape binary for bytea type + + + + Description + + stringpg_escape_bytea + stringdata + + + pg_escape_bytea escapes string for + bytea datatype. It returns escaped string. + + + + When you SELECT bytea type, PostgreSQL returns octal byte value + prefixed by \ (e.g. \032). Users are supposed to convert back to + binary format by yourself. + + + This function requires PostgreSQL 7.2 or later. With PostgreSQL + 7.2.0 and 7.2.1, bytea type must be casted when you enable + multi-byte support. i.e. INSERT INTO test_table (image) + VALUES ('$image_escaped'::bytea); PostgreSQL 7.2.2 or + later does not need cast. Exception is when client and backend + character encoding does not match, there may be multi-byte + stream error. User must cast to bytea to avoid this error. + + + + See also pg_unescape_bytea and + pg_escape_string. + + + + - - - pg_escape_string - - Escape string for text/char type - - - - Description - - stringpg_escape_string - stringdata - - - pg_escape_string escapes string for - text/char datatype. It returns escaped string for - PostgreSQL. Use of this function is recommended instead of - addslashes. + + + pg_escape_string + + Escape string for text/char type + + + + Description + + stringpg_escape_string + stringdata + + + pg_escape_string escapes string for + text/char datatype. It returns escaped string for + PostgreSQL. Use of this function is recommended instead of + addslashes. + + + + This function requires PostgreSQL 7.2 or later. - - - This function requires PostgreSQL 7.2 or later. - - - - See also pg_escape_bytea - - - + + + See also pg_escape_bytea + + + + - - - pg_fetch_all - Fetches all rows from a result as an array - - - Description - - arraypg_fetch_all - resourceresult - - - pg_fetch_all returns an array that - contains all rows (tuples/records) in result resource. It returns - &false;, if there are no rows. - - &database.fetch-null; - - - PostgreSQL fetch all - + + + pg_fetch_all + Fetches all rows from a result as an array + + + Description + + arraypg_fetch_all + resourceresult + + + pg_fetch_all returns an array that + contains all rows (tuples/records) in result resource. It returns + &false;, if there are no rows. + + &database.fetch-null; + + + PostgreSQL fetch all + ]]> - - - - - See also pg_fetch_row, - pg_fetch_array, - pg_fetch_object and - pg_fetch_result. - - - + + + + + See also pg_fetch_row, + pg_fetch_array, + pg_fetch_object and + pg_fetch_result. + + + + - - - pg_fetch_array - Fetch a row as an array - - - Description - - arraypg_fetch_array - resourceresult - introw - intresult_type - + + + pg_fetch_array + Fetch a row as an array + + + Description + + arraypg_fetch_array + resourceresult + introw + intresult_type + + + 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 (field index) to the result array, it + also stores the data in associative indices (field name) by + default. + + &database.fetch-null; + + row is row (record) number to be + retrieved. First row is 0. + + + result_type is an optional parameter that controls + how the return value is initialized. + result_type is a constant and can take the + following values: PGSQL_ASSOC, + PGSQL_NUM, and PGSQL_BOTH. + Using PGSQL_NUM, pg_fetch_array + will return an array with numerical indices, using + PGSQL_ASSOC will return only associative indices + while PGSQL_BOTH, the default, will return both + numerical and associative indices. + - pg_fetch_array returns an array that - corresponds to the fetched row (tuples/records). It returns - &false;, if there are no more rows. + result_type was added in PHP 4.0. - - pg_fetch_array is an extended version of - pg_fetch_row. In addition to storing the - data in the numeric indices (field index) to the result array, it - also stores the data in associative indices (field name) by - default. - - &database.fetch-null; - - row is row (record) number to be - retrieved. First row is 0. - - - result_type is an optional parameter that controls - how the return value is initialized. - result_type is a constant and can take the - following values: PGSQL_ASSOC, - PGSQL_NUM, and PGSQL_BOTH. - Using PGSQL_NUM, pg_fetch_array - will return an array with numerical indices, using - PGSQL_ASSOC will return only associative indices - while PGSQL_BOTH, the default, will return both - numerical and associative indices. - - - result_type was added in PHP 4.0. - - - - - pg_fetch_array is NOT significantly - slower than using pg_fetch_row, while it - provides a significant ease of use. - - - - <function>pg_fetch_array</function> example - + + + + pg_fetch_array is NOT significantly + slower than using pg_fetch_row, while it + provides a significant ease of use. + + + + <function>pg_fetch_array</function> example + ]]> - - - - - - From 4.1.0, row became optional. - Calling pg_fetch_array will increment - the internal row counter by one. - - - - See also - pg_fetch_row, - pg_fetch_object and - pg_fetch_result. - - - + + + + + + From 4.1.0, row became optional. + Calling pg_fetch_array will increment + the internal row counter by one. + + + + See also + pg_fetch_row, + pg_fetch_object and + pg_fetch_result. + + + + - - - pg_fetch_assoc - Fetch a row as an associative array - - - Description - - arraypg_fetch_assoc - resourceresult - introw - - - pg_fetch_assoc returns an associative array that - corresponds to the fetched row (tuples/records). It returns - &false;, if there are no more rows. - - - pg_fetch_assoc is equivalent to calling - pg_fetch_array with PGSQL_ASSOC for the - optional third parameter. It only returns an associative array. - If you need the numeric indices, use - pg_fetch_row. - - &database.fetch-null; - - row is row (record) number to be - retrieved. First row is 0. - - - pg_fetch_assoc is NOT significantly - slower than using pg_fetch_row, while it - provides a significant ease of use. - - - - <function>pg_fetch_assoc</function> example - + + + pg_fetch_assoc + Fetch a row as an associative array + + + Description + + arraypg_fetch_assoc + resourceresult + introw + + + pg_fetch_assoc returns an associative array that + corresponds to the fetched row (tuples/records). It returns + &false;, if there are no more rows. + + + pg_fetch_assoc is equivalent to calling + pg_fetch_array with PGSQL_ASSOC for the + optional third parameter. It only returns an associative array. + If you need the numeric indices, use + pg_fetch_row. + + &database.fetch-null; + + row is row (record) number to be + retrieved. First row is 0. + + + pg_fetch_assoc is NOT significantly + slower than using pg_fetch_row, while it + provides a significant ease of use. + + + + <function>pg_fetch_assoc</function> example + ]]> - - - - - - From 4.1.0, row became optional. - Calling pg_fetch_assoc will increment - the internal row counter by one. - - - - See also - pg_fetch_row, - pg_fetch_array, - pg_fetch_object and - pg_fetch_result. - - - + + + + + + From 4.1.0, row became optional. + Calling pg_fetch_assoc will increment + the internal row counter by one. + + + + See also + pg_fetch_row, + pg_fetch_array, + pg_fetch_object and + pg_fetch_result. + + + + - - - pg_fetch_object - Fetch a row as an object - - - Description - - objectpg_fetch_object - resourceresult - introw - intresult_type - - - 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 - pg_fetch_array, with one difference - an - object is returned, instead of an array. Indirectly, that means - that you can only access the data by the field names, and not by - their offsets (numbers are illegal property names). - - &database.fetch-null; - - row is row (record) number to be - retrieved. First row is 0. - - - Speed-wise, the function is identical to - pg_fetch_array, and almost as quick as - pg_fetch_row (the difference is - insignificant). - - - - From 4.3.0, result_type is default to PGSQL_ASSOC while - older versions' default was PGSQL_BOTH. There is no use for numeric property, - since numeric property name is invalid in PHP. - - - result_type may be deleted in future versions. - - - - - <function>pg_fetch_object</function> example - + + + pg_fetch_object + Fetch a row as an object + + + Description + + objectpg_fetch_object + resourceresult + introw + intresult_type + + + 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 + pg_fetch_array, with one difference - an + object is returned, instead of an array. Indirectly, that means + that you can only access the data by the field names, and not by + their offsets (numbers are illegal property names). + + &database.fetch-null; + + row is row (record) number to be + retrieved. First row is 0. + + + Speed-wise, the function is identical to + pg_fetch_array, and almost as quick as + pg_fetch_row (the difference is + insignificant). + + + + From 4.3.0, result_type is default to PGSQL_ASSOC while + older versions' default was PGSQL_BOTH. There is no use for numeric property, + since numeric property name is invalid in PHP. + + + result_type may be deleted in future versions. + + + + + <function>pg_fetch_object</function> example + author . " ("; - echo $data->year . "): "; - echo $data->title . "
"; - $row++; + echo $data->author . " ("; + echo $data->year . "): "; + echo $data->title . "
"; + $row++; } pg_free_result($qu); @@ -78,26 +78,26 @@ pg_close($db_conn); ?> ]]> -
-
-
- - - From 4.1.0, row became optional. - Calling pg_fetch_object will increment - the internal row counter counter by one. - - - - See also - pg_query, - pg_fetch_array, - pg_fetch_assoc, - pg_fetch_row and - pg_fetch_result. - -
-
+
+
+
+ + + From 4.1.0, row became optional. + Calling pg_fetch_object will increment + the internal row counter counter by one. + + + + See also + pg_query, + pg_fetch_array, + pg_fetch_assoc, + pg_fetch_row and + pg_fetch_result. + +
+
+ - - - pg_fetch_result - Returns values from a result resource - - - Description - - mixedpg_fetch_result - resourceresult - introw - mixedfield - - - mixedpg_fetch_result - resourceresult - mixedfield - - - pg_fetch_result returns values from a - result resource returned by - pg_query. row - is integer. field is field name (string) - or field index (integer). The row - and field specify 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. - - - PostgreSQL has many built in types and only the basic ones are - directly supported here. All forms of integer - - types are returned as integer values. All forms of - float, and real types are returned as float values. - Boolean is returned as "t" or "f". All - other types, including arrays are returned as strings formatted - in the same default PostgreSQL manner that you would see in the - psql program. - - - + + + pg_fetch_result + Returns values from a result resource + + + Description + + mixedpg_fetch_result + resourceresult + introw + mixedfield + + + mixedpg_fetch_result + resourceresult + mixedfield + + + pg_fetch_result returns values from a + result resource returned by + pg_query. row + is integer. field is field name (string) + or field index (integer). The row + and field specify 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. + + + PostgreSQL has many built in types and only the basic ones are + directly supported here. All forms of integer + + types are returned as integer values. All forms of + float, and real types are returned as float values. + Boolean is returned as "t" or "f". All + other types, including arrays are returned as strings formatted + in the same default PostgreSQL manner that you would see in the + psql program. + + + + - - - pg_fetch_row - Get a row as an enumerated array - - - Description - - arraypg_fetch_row - resourceresult - introw - - - 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. - - - It returns an array that corresponds to the fetched row, or &false; - if there are no more rows. - - &database.fetch-null; - - - <function>pg_fetch_row</function> example - + + + pg_fetch_row + Get a row as an enumerated array + + + Description + + arraypg_fetch_row + resourceresult + introw + + + 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. + + + It returns an array that corresponds to the fetched row, or &false; + if there are no more rows. + + &database.fetch-null; + + + <function>pg_fetch_row</function> example + \n"; + echo "Author: $row[0] E-mail: $row[1]"; + echo "
\n"; } ?> ]]> -
-
-
- - - From 4.1.0, row became optional. - Calling pg_fetch_row will increment - the internal row counter by one. - - - - See also - pg_query, - pg_fetch_array, - pg_fetch_object and - pg_fetch_result. - -
-
+
+
+
+ + + From 4.1.0, row became optional. + Calling pg_fetch_row will increment + the internal row counter by one. + + + + See also + pg_query, + pg_fetch_array, + pg_fetch_object and + pg_fetch_result. + +
+
+ - - - pg_field_is_null - Test if a field is &null; - - - Description - - intpg_field_is_null - resourceresult - introw - mixedfield - - - pg_field_is_null tests 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 column index (number) or fieldname (string). Row - numbering starts at 0. - - - - <function>pg_field_is_null</function> example - + + + pg_field_is_null + Test if a field is &null; + + + Description + + intpg_field_is_null + resourceresult + introw + mixedfield + + + pg_field_is_null tests 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 column index (number) or fieldname (string). Row + numbering starts at 0. + + + + <function>pg_field_is_null</function> example + ]]> - - - - - - This function used to be called pg_fieldisnull(). - - - - + + + + + + This function used to be called pg_fieldisnull(). + + + + + - - - pg_field_name - Returns the name of a field - - - Description - - stringpg_field_name - resourceresult - intfield_number - - - pg_field_name returns the name of the field - occupying the given field_number in the - given PostgreSQL result resource. Field - numbering starts from 0. - - - - Getting information about fields - + + + pg_field_name + Returns the name of a field + + + Description + + stringpg_field_name + resourceresult + intfield_number + + + pg_field_name returns the name of the field + occupying the given field_number in the + given PostgreSQL result resource. Field + numbering starts from 0. + + + + Getting information about fields + ]]> - - - The above example would produce the following output: - - + + + The above example would produce the following output: + + - - - - - - This function used to be called pg_fieldname(). - - - - See also pg_field_num. - - - + + + + + + This function used to be called pg_fieldname(). + + + + See also pg_field_num. + + + + - - - pg_field_num - Returns the field number of the named field - - - Description - - intpg_field_num - resourceresult - stringfield_name - - - pg_field_num will return the number of the - column (field) slot that corresponds to the - field_name in the given PostgreSQL - result resource. Field numbering starts - at 0. This function will return -1 on error. - - - See the example given at the pg_field_name page. - - - - This function used to be called pg_fieldnum(). - - - - See also pg_field_name. - - - + + + pg_field_num + Returns the field number of the named field + + + Description + + intpg_field_num + resourceresult + stringfield_name + + + pg_field_num will return the number of the + column (field) slot that corresponds to the + field_name in the given PostgreSQL + result resource. Field numbering starts + at 0. This function will return -1 on error. + + + See the example given at the pg_field_name page. + + + + This function used to be called pg_fieldnum(). + + + + See also pg_field_name. + + + + - - - pg_field_prtlen - Returns the printed length - - - Description - - intpg_field_prtlen - resourceresult - introw_number - mixedfield_name_or_number - - - pg_field_prtlen 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. - - - field_name_or_number can be passed either as an - integer or as a string. If it is passed as an - integer, PHP recognises it as the field number, otherwise as - field name. - - - See the example given at the pg_field_name page. - - - - This function used to be called pg_fieldprtlen(). - - - - See also pg_field_size. - - - + + + pg_field_prtlen + Returns the printed length + + + Description + + intpg_field_prtlen + resourceresult + introw_number + mixedfield_name_or_number + + + pg_field_prtlen 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. + + + field_name_or_number can be passed either as an + integer or as a string. If it is passed as an + integer, PHP recognises it as the field number, otherwise as + field name. + + + See the example given at the pg_field_name page. + + + + This function used to be called pg_fieldprtlen(). + + + + See also pg_field_size. + + + + - - - pg_field_size - - Returns the internal storage size of the named field - - - - Description - - intpg_field_size - resourceresult - intfield_number - - - pg_field_size 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 the example given at the pg_field_name page. - - - - This function used to be called pg_fieldsize(). - - - - See also pg_field_prtlen and - pg_field_type. - - - + + + pg_field_size + + Returns the internal storage size of the named field + + + + Description + + intpg_field_size + resourceresult + intfield_number + + + pg_field_size 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 the example given at the pg_field_name page. + + + + This function used to be called pg_fieldsize(). + + + + See also pg_field_prtlen and + pg_field_type. + + + - - - pg_field_type_oid - - Returns the type ID (OID) for the corresponding field number - - - - Description - - intpg_field_type_oid - resourceresult - intfield_number - - - pg_field_type_oid returns an integer containing the - type ID the given field_number in the - given PostgreSQL result resource. Field - numbering starts at 0. - - - You can get more information about the field type by querying PostgreSQL - pg_type system table using the ID obtained with this function. - - - See also pg_field_type, - pg_field_prtlen and - pg_field_name. - - - + + + + pg_field_type_oid + + Returns the type ID (OID) for the corresponding field number + + + + Description + + intpg_field_type_oid + resourceresult + intfield_number + + + pg_field_type_oid returns an integer containing the + type ID the given field_number in the + given PostgreSQL result resource. Field + numbering starts at 0. + + + You can get more information about the field type by querying PostgreSQL + pg_type system table using the ID obtained with this function. + + + See also pg_field_type, + pg_field_prtlen and + pg_field_name. + + + + - - - pg_field_type - - Returns the type name for the corresponding field number - - - - Description - - stringpg_field_type - resourceresult - intfield_number - - - pg_field_type returns a string containing the - type name of the given field_number in the - given PostgreSQL result resource. Field - numbering starts at 0. - - - See the example given at the pg_field_name page. - - - - This function used to be called pg_fieldtype(). - - - - See also pg_field_prtlen, - pg_field_name and - pg_field_type_oid. - - - + + + pg_field_type + + Returns the type name for the corresponding field number + + + + Description + + stringpg_field_type + resourceresult + intfield_number + + + pg_field_type returns a string containing the + type name of the given field_number in the + given PostgreSQL result resource. Field + numbering starts at 0. + + + See the example given at the pg_field_name page. + + + + This function used to be called pg_fieldtype(). + + + + See also pg_field_prtlen, + pg_field_name and + pg_field_type_oid. + + + + - - - pg_free_result - Free result memory - - - Description - - boolpg_free_result - resourceresult - - - pg_free_result only needs to be called if you - are worried about using too much memory while your script is - 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_free_result with the - result resource as an argument and the - associated result memory will be freed. &return.success; - - - - This function used to be called pg_freeresult(). - - - - See also pg_query. - - - + + + pg_free_result + Free result memory + + + Description + + boolpg_free_result + resourceresult + + + pg_free_result only needs to be called if you + are worried about using too much memory while your script is + 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_free_result with the + result resource as an argument and the + associated result memory will be freed. &return.success; + + + + This function used to be called pg_freeresult(). + + + + See also pg_query. + + + - - - pg_get_notify - Ping database connection - - - Description - - arraypg_get_notify - resourceconnection - intresult_type - - - pg_get_notify gets notify message sent by - NOTIFY SQL command. To receive notify - messages, LISTEN SQL command must be - issued. If there is notify message on the connection, array - contains message name and backend PID is returned. If there is no - message, &false; is returned. - - - See also pg_get_pid - - - - PostgreSQL NOTIFY message - + + + + pg_get_notify + Ping database connection + + + Description + + arraypg_get_notify + resourceconnection + intresult_type + + + pg_get_notify gets notify message sent by + NOTIFY SQL command. To receive notify + messages, LISTEN SQL command must be + issued. If there is notify message on the connection, array + contains message name and backend PID is returned. If there is no + message, &false; is returned. + + + See also pg_get_pid + + + + PostgreSQL NOTIFY message + ]]> - - - - - + + + + + - - - pg_get_pid - Ping database connection - - - Description - - intpg_get_pid - resourceconnection - - - pg_get_pid gets backend (database server - process) PID. PID is useful to check if NOTIFY - message is sent from other process or not. - - - - PostgreSQL backend PID - + + + + pg_get_pid + Ping database connection + + + Description + + intpg_get_pid + resourceconnection + + + pg_get_pid gets backend (database server + process) PID. PID is useful to check if NOTIFY + message is sent from other process or not. + + + + PostgreSQL backend PID + ]]> - - - - - See also pg_get_notify. - - - + + + + + See also pg_get_notify. + + + + - - - pg_get_result - - Get asynchronous query result - - - - Description - - resourcepg_get_result - resourceconnection - - - pg_get_result get result resource from async - query executed by - pg_send_query. pg_send_query - can send multiple queries to PostgreSQL server and - pg_get_result is used to get query result - one by one. It returns result resource. If there is no more - results, it returns &false;. - - - + + + pg_get_result + + Get asynchronous query result + + + + Description + + resourcepg_get_result + resourceconnection + + + pg_get_result get result resource from async + query executed by + pg_send_query. pg_send_query + can send multiple queries to PostgreSQL server and + pg_get_result is used to get query result + one by one. It returns result resource. If there is no more + results, it returns &false;. + + + + - - - pg_host - - Returns the host name associated with the connection - - - - Description - - stringpg_host - resourceconnection - - - pg_host returns the host name of the given - PostgreSQL connection resource is - connected to. - - - See also pg_connect and - pg_pconnect. - - - + + + pg_host + + Returns the host name associated with the connection + + + + Description + + stringpg_host + resourceconnection + + + pg_host returns the host name of the given + PostgreSQL connection resource is + connected to. + + + See also pg_connect and + pg_pconnect. + + + + - - - pg_insert - - Insert array into table - - - - Description - - boolpg_insert - resourceconnection - stringtable_name - arrayassoc_array - intoptions - - - pg_insert inserts the values of assoc_array - into the table specified by table_name. - table_name must at least have as many columns as - assoc_array has elements. The fieldnames as - well as the fieldvalues in table_name - must match the indices and values of assoc_array. - &return.success; - If options is specified, pg_insert - is applied to assoc_array with specified option. - - - - <function>pg_insert</function> example - + + + pg_insert + + Insert array into table + + + + Description + + boolpg_insert + resourceconnection + stringtable_name + arrayassoc_array + intoptions + + + pg_insert inserts the values of assoc_array + into the table specified by table_name. + table_name must at least have as many columns as + assoc_array has elements. The fieldnames as + well as the fieldvalues in table_name + must match the indices and values of assoc_array. + &return.success; + If options is specified, pg_insert + is applied to assoc_array with specified option. + + + + <function>pg_insert</function> example + ]]> - - - - &warn.experimental.func; - - See also pg_convert. - - - + + + + &warn.experimental.func; + + See also pg_convert. + + + + - - - pg_last_error - Get the last error message string of a connection - - - Description - - stringpg_last_error - resourceconnection - - - pg_last_error returns the last error message - for given connection. - - - Error messages may be overwritten by internal PostgreSQL(libpq) - function calls. It may not return appropriate error message, if - multiple errors are occurred inside a PostgreSQL module function. - - - Use pg_result_error, - pg_result_status and - pg_connection_status for better error handling. - - - - This function used to be called pg_errormessage(). - - - - See also pg_result_error. - - - + + + pg_last_error + Get the last error message string of a connection + + + Description + + stringpg_last_error + resourceconnection + + + pg_last_error returns the last error message + for given connection. + + + Error messages may be overwritten by internal PostgreSQL(libpq) + function calls. It may not return appropriate error message, if + multiple errors are occurred inside a PostgreSQL module function. + + + Use pg_result_error, + pg_result_status and + pg_connection_status for better error handling. + + + + This function used to be called pg_errormessage(). + + + + See also pg_result_error. + + + + - - - pg_last_notice - - Returns the last notice message from PostgreSQL server - - - - Description - - stringpg_last_notice - resourceconnection - - - pg_last_notice returns the last notice - message from the PostgreSQL server specified by - connection. The PostgreSQL server sends notice - messages in several cases, e.g. if the transactions can't be continued. - With pg_last_notice, you can avoid issuing useless - queries, by checking whether the notice is related to the transaction - or not. - - - - This function is EXPERIMENTAL and it is not fully implemented - yet. pg_last_notice was added in PHP - 4.0.6. However, PHP 4.0.6 has problem with notice message - handling. Use of the PostgreSQL module with PHP 4.0.6 is not - recommended even if you are not using - pg_last_notice. - - - This function is fully implemented in PHP 4.3.0. PHP earlier than - PHP 4.3.0 ignores database connection parameter. - - - - Notice message tracking can be set to optional by setting 1 for - pgsql.ignore_notice in &php.ini; from PHP 4.3.0. - - - Notice message logging can be set to optional by setting 0 for - pgsql.log_notice in &php.ini; from PHP 4.3.0. - Unless pgsql.ignore_notice is set - to 0, notice message cannot be logged. - - - See also pg_query and - pg_last_error. - - - + + + pg_last_notice + + Returns the last notice message from PostgreSQL server + + + + Description + + stringpg_last_notice + resourceconnection + + + pg_last_notice returns the last notice + message from the PostgreSQL server specified by + connection. The PostgreSQL server sends notice + messages in several cases, e.g. if the transactions can't be continued. + With pg_last_notice, you can avoid issuing useless + queries, by checking whether the notice is related to the transaction + or not. + + + + This function is EXPERIMENTAL and it is not fully implemented + yet. pg_last_notice was added in PHP + 4.0.6. However, PHP 4.0.6 has problem with notice message + handling. Use of the PostgreSQL module with PHP 4.0.6 is not + recommended even if you are not using + pg_last_notice. + + + This function is fully implemented in PHP 4.3.0. PHP earlier than + PHP 4.3.0 ignores database connection parameter. + + + + Notice message tracking can be set to optional by setting 1 for + pgsql.ignore_notice in &php.ini; from PHP 4.3.0. + + + Notice message logging can be set to optional by setting 0 for + pgsql.log_notice in &php.ini; from PHP 4.3.0. + Unless pgsql.ignore_notice is set + to 0, notice message cannot be logged. + + + See also pg_query and + pg_last_error. + + + + - - - pg_last_oid - Returns the last object's oid - - - Description - - intpg_last_oid - resourceresult - - - pg_last_oid 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_query 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_query was not an INSERT or INSERT is - failed. - - - OID field became an optional field from PostgreSQL 7.2. When - OID field is not defined in a table, programmer must use - pg_result_status to check if record is - is inserted successfully or not. - - - - This function used to be called pg_getlastoid(). - - - - See also pg_query and - pg_result_status - - - + + + pg_last_oid + Returns the last object's oid + + + Description + + intpg_last_oid + resourceresult + + + pg_last_oid 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_query 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_query was not an INSERT or INSERT is + failed. + + + OID field became an optional field from PostgreSQL 7.2. When + OID field is not defined in a table, programmer must use + pg_result_status to check if record is + is inserted successfully or not. + + + + This function used to be called pg_getlastoid(). + + + + See also pg_query and + pg_result_status + + + + - - - pg_lo_close - Close a large object - - - Description - - boolpg_lo_close - resourcelarge_object - - - pg_lo_close closes a Large - Object. large_object is a resource for the - large object from pg_lo_open. - - - To use the large object (lo) interface, it is necessary to - enclose it within a transaction block. - - - - This function used to be called pg_loclose(). - - - - See also pg_lo_open, - pg_lo_create and - pg_lo_import. - - - + + + pg_lo_close + Close a large object + + + Description + + boolpg_lo_close + resourcelarge_object + + + pg_lo_close closes a Large + Object. large_object is a resource for the + large object from pg_lo_open. + + + To use the large object (lo) interface, it is necessary to + enclose it within a transaction block. + + + + This function used to be called pg_loclose(). + + + + See also pg_lo_open, + pg_lo_create and + pg_lo_import. + + + + - - - pg_lo_create - Create a large object - - - Description - - intpg_lo_create - resourceconnection - - - pg_lo_create creates a Large - Object and returns the oid of the large - 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 returns &false; if an error occurred. - - - To use the large object (lo) interface, it is necessary to - enclose it within a transaction block. - - - - This function used to be called pg_locreate(). - - - - + + + pg_lo_create + Create a large object + + + Description + + intpg_lo_create + resourceconnection + + + pg_lo_create creates a Large + Object and returns the oid of the large + 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 returns &false; if an error occurred. + + + To use the large object (lo) interface, it is necessary to + enclose it within a transaction block. + + + + This function used to be called pg_locreate(). + + + + + - - - pg_lo_export - Export a large object to file - - - Description - - boolpg_lo_export - resourceconnection - intoid - stringpathname - - - 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. - - - - This function used to be called pg_loexport(). - - - - See also pg_lo_import. - - - + + + pg_lo_export + Export a large object to file + + + Description + + boolpg_lo_export + resourceconnection + intoid + stringpathname + + + 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. + + + + This function used to be called pg_loexport(). + + + + See also pg_lo_import. + + + + - - - pg_lo_import - Import a large object from file - - - Description - - intpg_lo_import - resourceconnection - stringpathname - - - In versions before PHP 4.2.0 the syntax of this function was different, - see the following definition: - - - intpg_lo_import - stringpathname - resourceconnection - - - 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; - - - This function used to be called pg_loimport(). - - - - See also pg_lo_export and - pg_lo_open. - - - + + + pg_lo_import + Import a large object from file + + + Description + + intpg_lo_import + resourceconnection + stringpathname + + + In versions before PHP 4.2.0 the syntax of this function was different, + see the following definition: + + + intpg_lo_import + stringpathname + resourceconnection + + + 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; + + + This function used to be called pg_loimport(). + + + + See also pg_lo_export and + pg_lo_open. + + + + - - - pg_lo_open - Open a large object - - - Description - - resourcepg_lo_open - resourceconnection - intoid - stringmode - - - pg_lo_open opens a Large Object and - 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. - - - - This function used to be called pg_loopen(). - - - - See also pg_lo_close and - pg_lo_create. - - - + + + pg_lo_open + Open a large object + + + Description + + resourcepg_lo_open + resourceconnection + intoid + stringmode + + + pg_lo_open opens a Large Object and + 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. + + + + This function used to be called pg_loopen(). + + + + See also pg_lo_close and + pg_lo_create. + + + + - - - pg_lo_read_all - - Reads an entire large object and send straight to browser - - - - Description - - intpg_lo_read_all - resourcelarge_object - - - pg_lo_read_all 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 occurred. - - - To use the large object (lo) interface, it is necessary to - enclose it within a transaction block. - - - - This function used to be called pg_loreadall(). - - - - See also pg_lo_read. - - - + + + pg_lo_read_all + + Reads an entire large object and send straight to browser + + + + Description + + intpg_lo_read_all + resourcelarge_object + + + pg_lo_read_all 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 occurred. + + + To use the large object (lo) interface, it is necessary to + enclose it within a transaction block. + + + + This function used to be called pg_loreadall(). + + + + See also pg_lo_read. + + + + - - - pg_lo_read - Read a large object - - - Description - - stringpg_lo_read - resourcelarge_object - intlen - - - pg_lo_read reads at most - len (defaults to 8192) 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. 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. - - - - This function used to be called pg_loread(). - - - - See also pg_lo_read_all. - - - + + + pg_lo_read + Read a large object + + + Description + + stringpg_lo_read + resourcelarge_object + intlen + + + pg_lo_read reads at most + len (defaults to 8192) 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. 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. + + + + This function used to be called pg_loread(). + + + + See also pg_lo_read_all. + + + + - - - pg_lo_seek - - Seeks position of large object - - - - Description - - boolpg_lo_seek - resourcelarge_object - intoffset - intwhence - - - pg_lo_seek seeks position of large object - resource. whence is PGSQL_SEEK_SET, - PGSQL_SEEK_CUR or PGSQL_SEEK_END. - - - See also pg_lo_tell. - - - + + + pg_lo_seek + + Seeks position of large object + + + + Description + + boolpg_lo_seek + resourcelarge_object + intoffset + intwhence + + + pg_lo_seek seeks position of large object + resource. whence is PGSQL_SEEK_SET, + PGSQL_SEEK_CUR or PGSQL_SEEK_END. + + + See also pg_lo_tell. + + + + - - - pg_lo_tell - - Returns current position of large object - - - - Description - - intpg_lo_tell - resourcelarge_object - - - pg_lo_tell returns current position (offset - from the beginning of large object). - - - See also pg_lo_seek. - - - + + + pg_lo_tell + + Returns current position of large object + + + + Description + + intpg_lo_tell + resourcelarge_object + + + pg_lo_tell returns current position (offset + from the beginning of large object). + + + See also pg_lo_seek. + + + + - - - pg_lo_unlink - Delete a large object - - - Description - - boolpg_lo_unlink - resourceconnection - intoid - - - pg_lo_unlink deletes a large object with the - oid. &return.success; - - - To use the large object (lo) interface, it is necessary to - enclose it within a transaction block. - - - - This function used to be called pg_lo_unlink(). - - - - See also pg_lo_create and - pg_lo_import. - - - + + + pg_lo_unlink + Delete a large object + + + Description + + boolpg_lo_unlink + resourceconnection + intoid + + + pg_lo_unlink deletes a large object with the + oid. &return.success; + + + To use the large object (lo) interface, it is necessary to + enclose it within a transaction block. + + + + This function used to be called pg_lo_unlink(). + + + + See also pg_lo_create and + pg_lo_import. + + + + - - - pg_lo_write - Write a large object - - - Description - - intpg_lo_write - resourcelarge_object - stringdata - intlen - - - pg_lo_write writes at most to a large object - 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_lo_open. - - - To use the large object (lo) interface, it is necessary to - enclose it within a transaction block. - - - - This function used to be called pg_lowrite(). - - - - See also pg_lo_create and - pg_lo_open. - - - + + + pg_lo_write + Write a large object + + + Description + + intpg_lo_write + resourcelarge_object + stringdata + intlen + + + pg_lo_write writes at most to a large object + 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_lo_open. + + + To use the large object (lo) interface, it is necessary to + enclose it within a transaction block. + + + + This function used to be called pg_lowrite(). + + + + See also pg_lo_create and + pg_lo_open. + + + + - - - pg_meta_data - - Get meta data for table - - - - Description - - arraypg_meta_data - resourceconnection - stringtable_name - - - pg_meta_data returns table definition for - table_name as an array. If there is error, it - returns &false; - - - - Getting table metadata - + + + pg_meta_data + + Get meta data for table + + + + Description + + arraypg_meta_data + resourceconnection + stringtable_name + + + pg_meta_data returns table definition for + table_name as an array. If there is error, it + returns &false; + + + + Getting table metadata + '; - var_dump($meta); - echo ''; - } + $meta = pg_meta_data($dbconn, 'authors'); + if (is_array($meta)) { + echo '
';
+      var_dump($meta);
+      echo '
'; + } ?> ]]> -
- - The above example would produce the following output: - - +
+ + The above example would produce the following output: + + - array(5) { - ["num"]=> - int(1) - ["type"]=> - string(7) "varchar" - ["len"]=> - int(-1) - ["not null"]=> - bool(false) - ["has default"]=> - bool(false) - } - ["year"]=> - array(5) { - ["num"]=> - int(2) - ["type"]=> - string(4) "int2" - ["len"]=> - int(2) - ["not null"]=> - bool(false) - ["has default"]=> - bool(false) - } - ["title"]=> - array(5) { - ["num"]=> - int(3) - ["type"]=> - string(7) "varchar" - ["len"]=> - int(-1) - ["not null"]=> - bool(false) - ["has default"]=> - bool(false) - } +["author"]=> +array(5) { + ["num"]=> + int(1) + ["type"]=> + string(7) "varchar" + ["len"]=> + int(-1) + ["not null"]=> + bool(false) + ["has default"]=> + bool(false) +} +["year"]=> +array(5) { + ["num"]=> + int(2) + ["type"]=> + string(4) "int2" + ["len"]=> + int(2) + ["not null"]=> + bool(false) + ["has default"]=> + bool(false) +} +["title"]=> +array(5) { + ["num"]=> + int(3) + ["type"]=> + string(7) "varchar" + ["len"]=> + int(-1) + ["not null"]=> + bool(false) + ["has default"]=> + bool(false) +} } ]]> - -
-
- &warn.experimental.func; - - See also pg_convert. - -
-
+ + + + &warn.experimental.func; + + See also pg_convert. + + + + - - - pg_num_fields - Returns the number of fields - - - Description - - intpg_num_fields - resourceresult - - - pg_num_fields returns the number of fields - (columns) in a PostgreSQL result. The - argument is a result resource returned by - pg_query. This function will return -1 on - error. - - - - This function used to be called pg_numfields(). - - - - See also pg_num_rows and - pg_affected_rows. - - - + + + pg_num_fields + Returns the number of fields + + + Description + + intpg_num_fields + resourceresult + + + pg_num_fields returns the number of fields + (columns) in a PostgreSQL result. The + argument is a result resource returned by + pg_query. This function will return -1 on + error. + + + + This function used to be called pg_numfields(). + + + + See also pg_num_rows and + pg_affected_rows. + + + + - - - pg_num_rows - Returns the number of rows - - - Description - - intpg_num_rows - resourceresult - - - pg_num_rows will return the number of rows in - a PostgreSQL result resource. - result is a query result resource returned - by pg_query. This function will return -1 on - error. - - - - Use pg_affected_rows to get number of rows - affected by INSERT, UPDATE and DELETE query. - - - - - This function used to be called pg_numrows(). - - - - See also pg_num_fields and - pg_affected_rows. - - - + + + pg_num_rows + Returns the number of rows + + + Description + + intpg_num_rows + resourceresult + + + pg_num_rows will return the number of rows in + a PostgreSQL result resource. + result is a query result resource returned + by pg_query. This function will return -1 on + error. + + + + Use pg_affected_rows to get number of rows + affected by INSERT, UPDATE and DELETE query. + + + + + This function used to be called pg_numrows(). + + + + See also pg_num_fields and + pg_affected_rows. + + + + - - - pg_options - Get the options associated with the connection - - - Description - - stringpg_options - resourceconnection - - - pg_options will return a string containing - the options specified on the given PostgreSQL - connection resource. - - - + + + pg_options + Get the options associated with the connection + + + Description + + stringpg_options + resourceconnection + + + pg_options will return a string containing + the options specified on the given PostgreSQL + connection resource. + + + + - - - pg_pconnect - Open a persistent PostgreSQL connection - - - Description - - resourcepg_pconnect - stringconnection_string - intconnect_type - - - pg_pconnect opens a connection to a - PostgreSQL database. It returns a connection resource that is - needed by other PostgreSQL functions. - - - For a description of the connection_string - parameter, see pg_connect. - - - To enable persistent connection, the pgsql.allow_persistent - &php.ini; directive must be set to "On" (which is the default). - The maximum number of persistent connection can be defined with the pgsql.max_persistent - &php.ini; directive (defaults to -1 for no limit). The total number - of connections can be set with the pgsql.max_links - &php.ini; directive. - - - pg_close will not close persistent links - generated by pg_pconnect. - - - See also pg_connect, and the section - Persistent Database - Connections for more information. - - - + + + pg_pconnect + Open a persistent PostgreSQL connection + + + Description + + resourcepg_pconnect + stringconnection_string + intconnect_type + + + pg_pconnect opens a connection to a + PostgreSQL database. It returns a connection resource that is + needed by other PostgreSQL functions. + + + For a description of the connection_string + parameter, see pg_connect. + + + To enable persistent connection, the pgsql.allow_persistent + &php.ini; directive must be set to "On" (which is the default). + The maximum number of persistent connection can be defined with the pgsql.max_persistent + &php.ini; directive (defaults to -1 for no limit). The total number + of connections can be set with the pgsql.max_links + &php.ini; directive. + + + pg_close will not close persistent links + generated by pg_pconnect. + + + See also pg_connect, and the section + Persistent Database + Connections for more information. + + + + - - - pg_ping - Ping database connection - - - Description - - boolpg_ping - resourceconnection - - - pg_ping ping database connection, try to - reconnect if it is broken. It returns &true; if connection is - alive, otherwise &false;. - - - - <function>pg_ping</function> example - + + + pg_ping + Ping database connection + + + Description + + boolpg_ping + resourceconnection + + + pg_ping ping database connection, try to + reconnect if it is broken. It returns &true; if connection is + alive, otherwise &false;. + + + + <function>pg_ping</function> example + ]]> - - - - - See also pg_connection_status and - pg_connection_reset. - - - + + + + + See also pg_connection_status and + pg_connection_reset. + + + + - - - pg_port - - Return the port number associated with the connection - - - - Description - - intpg_port - resourceconnection - - - pg_port returns the port number that the - given PostgreSQL connection resource is - connected to. - - - + + + pg_port + + Return the port number associated with the connection + + + + Description + + intpg_port + resourceconnection + + + pg_port returns the port number that the + given PostgreSQL connection resource is + connected to. + + + + - - - pg_put_line - Send a NULL-terminated string to PostgreSQL backend - - - Description - - boolpg_put_line - stringdata - - - boolpg_put_line - resourceconnection - stringdata - - - pg_put_line sends a NULL-terminated string - 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. &return.success; - - - - The application must explicitly send the two characters "\." - on the last line to indicate to the backend that it has finished - sending its data. - - - - - High-speed insertion of data into a table - + + + pg_put_line + Send a NULL-terminated string to PostgreSQL backend + + + Description + + boolpg_put_line + stringdata + + + boolpg_put_line + resourceconnection + stringdata + + + pg_put_line sends a NULL-terminated string + 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. &return.success; + + + + The application must explicitly send the two characters "\." + on the last line to indicate to the backend that it has finished + sending its data. + + + + + High-speed insertion of data into a table + ]]> - - - - - - Use of the pg_put_line causes most large object - operations, including pg_lo_read and - pg_lo_tell, to subsequently fail. You can use - pg_copy_from and pg_copy_to - instead. - - - - See also pg_end_copy. - - - + + + + + + Use of the pg_put_line causes most large object + operations, including pg_lo_read and + pg_lo_tell, to subsequently fail. You can use + pg_copy_from and pg_copy_to + instead. + + + + See also pg_end_copy. + + + + - - - pg_query - Execute a query - - - Description - - resourcepg_query - stringquery - - - resourcepg_query - resourceconnection - stringquery - - - pg_query 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_last_error - function if connection is valid. - pg_query 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. - - - connection is an optional parameter for - pg_query. If - connection is not set, default - connection is used. Default connection is the last connection - made by pg_connect or - pg_pconnect. - - - Although connection can be omitted, it - is not recommended, since it could be a cause of hard to find - bug in script. - - - - - - This function used to be called pg_exec(). - pg_exec() is still available for compatibility - reasons but users are encouraged to use the newer name. - - - - See also pg_connect, - pg_pconnect, - pg_fetch_array, - pg_fetch_object, - pg_num_rows and - pg_affected_rows. - - - + + + pg_query + Execute a query + + + Description + + resourcepg_query + stringquery + + + resourcepg_query + resourceconnection + stringquery + + + pg_query 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_last_error + function if connection is valid. + pg_query 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. + + + connection is an optional parameter for + pg_query. If + connection is not set, default + connection is used. Default connection is the last connection + made by pg_connect or + pg_pconnect. + + + Although connection can be omitted, it + is not recommended, since it could be a cause of hard to find + bug in script. + + + + + + This function used to be called pg_exec(). + pg_exec() is still available for compatibility + reasons but users are encouraged to use the newer name. + + + + See also pg_connect, + pg_pconnect, + pg_fetch_array, + pg_fetch_object, + pg_num_rows and + pg_affected_rows. + + + + - - - pg_result_error - - Get error message associated with result - - - - Description - - stringpg_result_error - resourceresult - - - pg_result_error returns error message - associated with result resource. Therefore, - user has better chance to get better error message than - pg_last_error. - - - Because pg_query returns &false; if the query fails, - you must use pg_send_query and - pg_get_result to get the result handle. - - - See also pg_query, - pg_send_query, - pg_get_result, - pg_last_error and - pg_last_notice - - - + + + pg_result_error + + Get error message associated with result + + + + Description + + stringpg_result_error + resourceresult + + + pg_result_error returns error message + associated with result resource. Therefore, + user has better chance to get better error message than + pg_last_error. + + + Because pg_query returns &false; if the query fails, + you must use pg_send_query and + pg_get_result to get the result handle. + + + See also pg_query, + pg_send_query, + pg_get_result, + pg_last_error and + pg_last_notice + + + + - - - pg_result_seek - Set internal row offset in result resource - - - Description - - arraypg_result_seek - resourceresult - intoffset - - - pg_result_seek set internal row offset in - result resource. It returns &false;, if there is error. - - - See also pg_fetch_row, - pg_fetch_assoc, - pg_fetch_array, - pg_fetch_object and - pg_fetch_result. - - - + + + pg_result_seek + Set internal row offset in result resource + + + Description + + arraypg_result_seek + resourceresult + intoffset + + + pg_result_seek set internal row offset in + result resource. It returns &false;, if there is error. + + + See also pg_fetch_row, + pg_fetch_assoc, + pg_fetch_array, + pg_fetch_object and + pg_fetch_result. + + + + - - - pg_result_status - - Get status of query result - - - - Description - - intpg_result_status - resourceresult - - - pg_result_status returns status of result - resource. Possible return values are PGSQL_EMPTY_QUERY, - PGSQL_COMMAND_OK, PGSQL_TUPLES_OK, PGSQL_COPY_TO, - PGSQL_COPY_FROM, PGSQL_BAD_RESPONSE, PGSQL_NONFATAL_ERROR and - PGSQL_FATAL_ERROR. - - - See also pg_connection_status. - - - + + + pg_result_status + + Get status of query result + + + + Description + + intpg_result_status + resourceresult + + + pg_result_status returns status of result + resource. Possible return values are PGSQL_EMPTY_QUERY, + PGSQL_COMMAND_OK, PGSQL_TUPLES_OK, PGSQL_COPY_TO, + PGSQL_COPY_FROM, PGSQL_BAD_RESPONSE, PGSQL_NONFATAL_ERROR and + PGSQL_FATAL_ERROR. + + + See also pg_connection_status. + + + + - - - pg_select - - Select records - - - - Description - - arraypg_select - resourceconnection - stringtable_name - arrayassoc_array - intoptions - - - pg_select selects records specified by - assoc_array which has - field=>value. For successful query, it returns - array contains all records and fields that match the condition - specified by assoc_array. If - options is specified, - pg_convert is applied to - assoc_array with specified option. - - - - <function>pg_select</function> example - + + + pg_select + + Select records + + + + Description + + arraypg_select + resourceconnection + stringtable_name + arrayassoc_array + intoptions + + + pg_select selects records specified by + assoc_array which has + field=>value. For successful query, it returns + array contains all records and fields that match the condition + specified by assoc_array. If + options is specified, + pg_convert is applied to + assoc_array with specified option. + + + + <function>pg_select</function> example + ]]> - - - - &warn.experimental.func; - - See also pg_convert - - - + + + + &warn.experimental.func; + + See also pg_convert + + + + - - - pg_send_query - - Sends asynchronous query - - - - Description - - boolpg_send_query - resourceconnection - stringquery - - - boolpg_send_query - stringquery - - - pg_send_query send asynchronous query to the - connection. Unlike - pg_query, it can send multiple query to - PostgreSQL and get the result one by one using - pg_get_result. Script execution is not blocked - while query is executing. Use - pg_connection_busy to check connection is - busy (i.e. query is executing). Query may be cancelled by calling - pg_cancel_query. - - - Although user can send multiple query at once, user cannot send - multiple query over busy connection. If query is sent while - connection is busy, it waits until last query is finished and - discards all result. - - - - Asynchronous Queries - + + + pg_send_query + + Sends asynchronous query + + + + Description + + boolpg_send_query + resourceconnection + stringquery + + + boolpg_send_query + stringquery + + + pg_send_query send asynchronous query to the + connection. Unlike + pg_query, it can send multiple query to + PostgreSQL and get the result one by one using + pg_get_result. Script execution is not blocked + while query is executing. Use + pg_connection_busy to check connection is + busy (i.e. query is executing). Query may be cancelled by calling + pg_cancel_query. + + + Although user can send multiple query at once, user cannot send + multiple query over busy connection. If query is sent while + connection is busy, it waits until last query is finished and + discards all result. + + + + Asynchronous Queries + ]]> - - - The above example would produce the following output: - - + + + The above example would produce the following output: + + - - - - - See also pg_query, - pg_cancel_query, - pg_get_result and - pg_connection_busy. - - - + + + + + See also pg_query, + pg_cancel_query, + pg_get_result and + pg_connection_busy. + + + + - - - pg_set_client_encoding - - Set the client encoding - - - - Description - - intpg_set_client_encoding - stringencoding - - - intpg_set_client_encoding - resourceconnection - stringencoding - - - pg_set_client_encoding sets the client - encoding and returns 0 if success or -1 if error. - - - encoding is the client encoding and can 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. Available encoding depends on your PostgreSQL and libpq - version. Refer to PostgreSQL manual for supported encodings for - your PostgreSQL. - - - - This function requires PHP-4.0.3 or higher and PostgreSQL-7.0 or - higher. Supported encoding depends on PostgreSQL version. Refer - to PostgreSQL manual for details. - - - The function used to be called - pg_setclientencoding(). - - - - See also pg_client_encoding. - - - + + + pg_set_client_encoding + + Set the client encoding + + + + Description + + intpg_set_client_encoding + stringencoding + + + intpg_set_client_encoding + resourceconnection + stringencoding + + + pg_set_client_encoding sets the client + encoding and returns 0 if success or -1 if error. + + + encoding is the client encoding and can 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. Available encoding depends on your PostgreSQL and libpq + version. Refer to PostgreSQL manual for supported encodings for + your PostgreSQL. + + + + This function requires PHP-4.0.3 or higher and PostgreSQL-7.0 or + higher. Supported encoding depends on PostgreSQL version. Refer + to PostgreSQL manual for details. + + + The function used to be called + pg_setclientencoding(). + + + + See also pg_client_encoding. + + + + - - - pg_trace - Enable tracing a PostgreSQL connection - - - Description - - boolpg_trace - stringpathname - stringmode - resourceconnection - - - 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. - - - pathname and mode - are the same as in fopen - (mode defaults to 'w'), - connection specifies the connection to - trace and defaults to the last one opened. - - - pg_trace returns &true; if - pathname could be opened for logging, - &false; otherwise. - - - See also fopen and - pg_untrace. - - - + + + pg_trace + Enable tracing a PostgreSQL connection + + + Description + + boolpg_trace + stringpathname + stringmode + resourceconnection + + + 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. + + + pathname and mode + are the same as in fopen + (mode defaults to 'w'), + connection specifies the connection to + trace and defaults to the last one opened. + + + pg_trace returns &true; if + pathname could be opened for logging, + &false; otherwise. + + + See also fopen and + pg_untrace. + + + + - - - pg_tty - - Return the tty name associated with the connection - - - - Description - - stringpg_tty - resourceconnection - - - pg_tty returns the tty name that server - side debugging output is sent to on the given PostgreSQL - connection resource. - - - + + + pg_tty + + Return the tty name associated with the connection + + + + Description + + stringpg_tty + resourceconnection + + + pg_tty returns the tty name that server + side debugging output is sent to on the given PostgreSQL + connection resource. + + + + - - - pg_unescape_bytea - - Unescape binary for bytea type - - - - Description - - stringpg_unescape_bytea - stringdata - - - pg_unescape_bytea unescapes string from - bytea datatype. It returns unescaped string (binary). - - - - When you SELECT bytea type, PostgreSQL returns octal byte value - prefixed by \ (e.g. \032). Users are supposed to convert back to - binary format by yourself. - - - This function requires PostgreSQL 7.2 or later. With PostgreSQL - 7.2.0 and 7.2.1, bytea type must be casted when you enable - multi-byte support. i.e. INSERT INTO test_table (image) - VALUES ('$image_escaped'::bytea); PostgreSQL 7.2.2 or - later does not need cast. Exception is when client and backend - character encoding does not match, there may be multi-byte - stream error. User must cast to bytea to avoid this error. - - - - See also pg_escape_bytea and - pg_escape_string - - - + + + pg_unescape_bytea + + Unescape binary for bytea type + + + + Description + + stringpg_unescape_bytea + stringdata + + + pg_unescape_bytea unescapes string from + bytea datatype. It returns unescaped string (binary). + + + + When you SELECT bytea type, PostgreSQL returns octal byte value + prefixed by \ (e.g. \032). Users are supposed to convert back to + binary format by yourself. + + + This function requires PostgreSQL 7.2 or later. With PostgreSQL + 7.2.0 and 7.2.1, bytea type must be casted when you enable + multi-byte support. i.e. INSERT INTO test_table (image) + VALUES ('$image_escaped'::bytea); PostgreSQL 7.2.2 or + later does not need cast. Exception is when client and backend + character encoding does not match, there may be multi-byte + stream error. User must cast to bytea to avoid this error. + + + + See also pg_escape_bytea and + pg_escape_string + + + + - - - pg_untrace - Disable tracing of a PostgreSQL connection - - - Description - - boolpg_untrace - resourceconnection - - - Stop tracing started by pg_trace. - connection specifies the connection that was - traced and defaults to the last one opened. - - - Returns always &true;. - - - See also pg_trace. - - - + + + pg_untrace + Disable tracing of a PostgreSQL connection + + + Description + + boolpg_untrace + resourceconnection + + + Stop tracing started by pg_trace. + connection specifies the connection that was + traced and defaults to the last one opened. + + + Returns always &true;. + + + See also pg_trace. + + + + - - - pg_update - - Update table - - - - Description - - mixedpg_update - resourceconnection - stringtable_name - arraydata - arraycondition - intoptions - - - pg_update updates records that matches - condition with data. If - options is specified, - pg_convert is applied to - data with specified options. - - - - <function>pg_update</function> example - + + + pg_update + + Update table + + + + Description + + mixedpg_update + resourceconnection + stringtable_name + arraydata + arraycondition + intoptions + + + pg_update updates records that matches + condition with data. If + options is specified, + pg_convert is applied to + data with specified options. + + + + <function>pg_update</function> example + 'AA', 'field2'=>'BB'); - - // This is safe, since $_POST is converted automatically - $res = pg_update($db, 'post_log', $_POST, $data); - if ($res) { - echo "Data is updated: $res\n"; - } else { - echo "User must have sent wrong inputs\n"; - } + $db = pg_connect('dbname=foo'); + $data = array('field1'=>'AA', 'field2'=>'BB'); + + // This is safe, since $_POST is converted automatically + $res = pg_update($db, 'post_log', $_POST, $data); + if ($res) { + echo "Data is updated: $res\n"; + } else { + echo "User must have sent wrong inputs\n"; + } ?> ]]> - - - - &warn.experimental.func; - - See also pg_convert. - - - + + + + &warn.experimental.func; + + See also pg_convert. + + + - - PostgreSQL Functions - PostgreSQL + + + PostgreSQL Functions + PostgreSQL - -
- &reftitle.intro; + +
+ &reftitle.intro; + + PostgreSQL database is Open Source product and available without + cost. 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/SQL99 language support, transactions, referential integrity, + stored procedures and type extensibility. PostgreSQL is an open source + descendant of this original Berkeley code. + +
+ +
+ &reftitle.required; + + To use PostgreSQL support, you need PostgreSQL 6.5 or + later, PostgreSQL 7.0 or later to enable all PostgreSQL module + features. PostgreSQL supports many character encoding including + multibyte character encoding. The current version and more + information about PostgreSQL is available at + &url.pgsql; and + &url.pgsql.techdocs;. + +
+ + &reference.pgsql.configure; + + &reference.pgsql.ini; + +
+ How to use and hints + - PostgreSQL database is Open Source product and available without - cost. 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/SQL99 language support, transactions, referential integrity, - stored procedures and type extensibility. PostgreSQL is an open source - descendant of this original Berkeley code. - -
- -
- &reftitle.required; - - To use PostgreSQL support, you need PostgreSQL 6.5 or - later, PostgreSQL 7.0 or later to enable all PostgreSQL module - features. PostgreSQL supports many character encoding including - multibyte character encoding. The current version and more - information about PostgreSQL is available at - &url.pgsql; and - &url.pgsql.techdocs;. - -
- - &reference.pgsql.configure; - - &reference.pgsql.ini; - -
- How to use and hints - - - Using the PostgreSQL module with PHP 4.0.6 is not recommended due to - a bug in the notice message handling code. Use 4.1.0 or later. - - - - - PostgreSQL function names will be changed in 4.2.0 release to - confirm to current coding standards. Most of new names will have - additional underscores, e.g. pg_lo_open(). Some functions are - renamed to different name for consistency. e.g. pg_exec() to - pg_query(). Older names can be used in 4.2.0 and a few releases - from 4.2.0, but they may be deleted in the future. - - - Function names changed - - - - Old name - New name - - - - - pg_cmdtuples - pg_affected_rows - - - pg_errormessage - pg_last_error - - - pg_exec - pg_query - - - pg_fieldname - pg_field_name - - - pg_fieldsize - pg_field_size - - - pg_fieldnum - pg_field_num - - - pg_fieldprtlen - pg_field_prtlen - - - pg_fieldisnull - pg_field_is_null - - - pg_freeresult - pg_free_result - - - pg_getlastoid - pg_last_oid - - - pg_loreadall - pg_lo_read_all - - - pg_locreate - pg_lo_create - - - pg_lounlink - pg_lo_unlink - - - pg_loopen - pg_lo_open - - - pg_loclose - pg_lo_close - - - pg_loread - pg_lo_read - - - pg_lowrite - pg_lo_write - - - pg_loimport - pg_lo_import - - - pg_loexport - pg_lo_export - - - pg_numrows - pg_num_rows - - - pg_numfields - pg_num_fields - - - pg_result - pg_fetch_result - - - -
- - The old pg_connect/pg_pconnect - syntax will be deprecated to support asynchronous connections in the - future. Please use a connection string for pg_connect - and pg_pconnect. + Using the PostgreSQL module with PHP 4.0.6 is not recommended due to + a bug in the notice message handling code. Use 4.1.0 or later.
+ + + PostgreSQL function names will be changed in 4.2.0 release to + confirm to current coding standards. Most of new names will have + additional underscores, e.g. pg_lo_open(). Some functions are + renamed to different name for consistency. e.g. pg_exec() to + pg_query(). Older names can be used in 4.2.0 and a few releases + from 4.2.0, but they may be deleted in the future. + + + Function names changed + + + + Old name + New name + + + + + pg_cmdtuples + pg_affected_rows + + + pg_errormessage + pg_last_error + + + pg_exec + pg_query + + + pg_fieldname + pg_field_name + + + pg_fieldsize + pg_field_size + + + pg_fieldnum + pg_field_num + + + pg_fieldprtlen + pg_field_prtlen + + + pg_fieldisnull + pg_field_is_null + + + pg_freeresult + pg_free_result + + + pg_getlastoid + pg_last_oid + + + pg_loreadall + pg_lo_read_all + + + pg_locreate + pg_lo_create + + + pg_lounlink + pg_lo_unlink + + + pg_loopen + pg_lo_open + + + pg_loclose + pg_lo_close + + + pg_loread + pg_lo_read + + + pg_lowrite + pg_lo_write + + + pg_loimport + pg_lo_import + + + pg_loexport + pg_lo_export + + + pg_numrows + pg_num_rows + + + pg_numfields + pg_num_fields + + + pg_result + pg_fetch_result + + + +
- Not all functions are supported by all builds. It depends on your - libpq (The PostgreSQL C Client interface) version and how libpq is - compiled. If there is missing function, libpq does not support - the feature required for the function. + The old pg_connect/pg_pconnect + syntax will be deprecated to support asynchronous connections in the + future. Please use a connection string for pg_connect + and pg_pconnect. - - It is also important that you do not use an older libpq than the PostgreSQL - Server to which you will be connecting. 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 opened 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 its meaning is: "listen on - TCP/IP sockets as well as Unix domain sockets". - - Postmaster and PHP - - - - Postmaster - PHP - Status - - - - - postmaster & - pg_connect("dbname=MyDbName"); - OK - - - postmaster -i & - pg_connect("dbname=MyDbName"); - OK - - - postmaster & - pg_connect("host=localhost dbname=MyDbName"); - - 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.php on line 20. - - - - postmaster -i & - pg_connect("host=localhost dbname=MyDbName"); - OK - - - -
-
- - 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") - - has been deprecated. - - - Environmental variables affect PostgreSQL server/client - behavior. For example, PostgreSQL module will lookup PGHOST - environment variable when the hostname is omitted in the connection - string. Supported environment variables are different from version - to version. Refer to PostgreSQL Programmer's Manual (libpq - - Environment Variables) for details. - - - Make sure you set environment variables for appropriate user. Use - $_ENV or getenv to check - which environment variables are available to the current process. - - - Setting default parameters - +
+ + Not all functions are supported by all builds. It depends on your + libpq (The PostgreSQL C Client interface) version 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 do not use an older libpq than the PostgreSQL + Server to which you will be connecting. 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 opened 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 its meaning is: "listen on + TCP/IP sockets as well as Unix domain sockets". + + Postmaster and PHP + + + + Postmaster + PHP + Status + + + + + postmaster & + pg_connect("dbname=MyDbName"); + OK + + + postmaster -i & + pg_connect("dbname=MyDbName"); + OK + + + postmaster & + pg_connect("host=localhost dbname=MyDbName"); + + 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.php on line 20. + + + + postmaster -i & + pg_connect("host=localhost dbname=MyDbName"); + OK + + + +
+
+ + 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") + + has been deprecated. + + + Environmental variables affect PostgreSQL server/client + behavior. For example, PostgreSQL module will lookup PGHOST + environment variable when the hostname is omitted in the connection + string. Supported environment variables are different from version + to version. Refer to PostgreSQL Programmer's Manual (libpq - + Environment Variables) for details. + + + Make sure you set environment variables for appropriate user. Use + $_ENV or getenv to check + which environment variables are available to the current process. + + + Setting default parameters + - - - - - PostgreSQL automatically folds all identifiers (e.g. table/column names) - to lower-case values. To get it to recognize upper-case values, you must - always wrap the identifier in quotes. - - -
- - &reference.pgsql.constants; - -
- &reftitle.examples; + + + - Starting with PostgreSQL 7.1.0, you can store up to 1GB into a - field of type text. In older versions, this was limited to the block - size (default was 8KB, maximum was 32KB, defined at compile time) + PostgreSQL automatically folds all identifiers (e.g. table/column names) + to lower-case values. To get it to recognize upper-case values, you must + always wrap the identifier in quotes. - - 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 - + +
+ + &reference.pgsql.constants; + +
+ &reftitle.examples; + + Starting with PostgreSQL 7.1.0, you can store up to 1GB into a + field of type text. In older versions, this was limited to the block + size (default was 8KB, maximum was 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 + ]]> - - - You should not close the connection to the PostgreSQL server - before closing the large object. - -
-
+ + + You should not close the connection to the PostgreSQL server + before closing the large object. + +
+
&reference.pgsql.functions; -
+
+