PHP PostgreSQL Functions
EditRocket provides the following information on PostgreSQL functions in the PHP source code builder.
int pg_affected_rows ( resource $result ) - pg_affected_rows() returns the number of tuples (instances/records/rows) affected by INSERT, UPDATE, and DELETE queries.
bool pg_cancel_query ( resource $connection ) -
string pg_client_encoding ([ resource $connection ] ) - PostgreSQL supports automatic character set conversion between server and client for certain character sets. pg_client_encoding() returns the client encoding as a string. The returned string will be one of the standard PostgreSQL encoding identifiers.
bool pg_close ([ resource $connection ] ) - pg_close() closes the non-persistent connection to a PostgreSQL database associated with the given connection resource.
resource pg_connect ( string $connection_string [, int $connect_type ] ) - pg_connect() opens a connection to a PostgreSQL database specified by the connection_string.
bool pg_connection_busy ( resource $connection ) - pg_connection_busy() determines whether or not a connection is busy. If it is busy, a previous query is still executing.
bool pg_connection_reset ( resource $connection ) - pg_connection_reset() resets the connection. It is useful for error recovery.
int pg_connection_status ( resource $connection ) - pg_connection_status() returns the status of the specified connection.
array pg_convert ( resource $connection , string $table_name , array $assoc_array [, int $options ] ) - 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 in table_name must match the indices in assoc_array and the corresponding datatypes must be compatible. Returns an array with the converted values on success, FALSE otherwise.
bool pg_copy_from ( resource $connection , string $table_name , array $rows [, string $delimiter [, string $null_as ]] ) - pg_copy_from() inserts records into a table from rows. It issues a COPY FROM SQL command internally to insert records.
array pg_copy_to ( resource $connection , string $table_name [, string $delimiter [, string $null_as ]] ) - pg_copy_to() copies a table to an array. It issues COPY TO SQL command internally to retrieve records.
string pg_dbname ([ resource $connection ] ) - pg_dbname() returns the name of the database that the given PostgreSQL connection resource.
mixed pg_delete ( resource $connection , string $table_name , array $assoc_array [, int $options ] ) - pg_delete() deletes records from a table specified by the keys and values in assoc_array.
bool pg_end_copy ([ resource $connection ] ) -
string pg_escape_bytea ([ resource $connection ], string $data ) - pg_escape_bytea() escapes string for bytea datatype. It returns escaped string.
string pg_escape_string ([ resource $connection ], string $data ) - pg_escape_string() escapes a string for insertion into the database. It returns an escaped string in the PostgreSQL format.
resource pg_execute ( resource $connection , string $stmtname , array $params ) -
array pg_fetch_all ( resource $result ) - pg_fetch_all() returns an array that contains all rows (records) in the result resource.
array pg_fetch_all_columns ( resource $result [, int $column ] ) - pg_fetch_all_columns() returns an array that contains all rows (records) in a particular column of the result resource.
array pg_fetch_array ( resource $result [, int $row [, int $result_type ]] ) - pg_fetch_array() returns an array that corresponds to the fetched row (record).
array pg_fetch_assoc ( resource $result [, int $row ] ) - pg_fetch_assoc() returns an associative array that corresponds to the fetched row (records).
object pg_fetch_object ( resource $result [, int $row [, int $result_type ]] ) -
string pg_fetch_result ( resource $result , int $row , mixed $field ) -
array pg_fetch_row ( resource $result [, int $row ] ) - pg_fetch_row() fetches one row of data from the result associated with the specified result resource.
int pg_field_is_null ( resource $result , int $row , mixed $field ) -
string pg_field_name ( resource $result , int $field_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.
int pg_field_num ( resource $result , string $field_name ) - pg_field_num() will return the number of the field number that corresponds to the field_name in the given PostgreSQL result resource.
int pg_field_prtlen ( resource $result , int $row_number , mixed $field_name_or_number ) -
int pg_field_size ( resource $result , int $field_number ) - pg_field_size() returns the internal storage size (in bytes) of the field number in the given PostgreSQL result.
mixed pg_field_table ( resource $result , int $field_number [, bool $oid_only ] ) - pg_field_table() returns the name of the table that field belongs to, or the table's oid if oid_only is TRUE.
string pg_field_type ( resource $result , int $field_number ) - pg_field_type() returns a string containing the base type name of the given field_number in the given PostgreSQL result resource.
int pg_field_type_oid ( resource $result , int $field_number ) - pg_field_type_oid() returns an integer containing the OID of the base type of the given field_number in the given PostgreSQL result resource.
bool pg_free_result ( resource $result ) -
array pg_get_notify ( resource $connection [, int $result_type ] ) - pg_get_notify() gets notifications generated by a NOTIFY SQL command. To receive notifications, the LISTEN SQL command must be issued.
int pg_get_pid ( resource $connection ) - pg_get_pid() gets the backend's (database server process) PID.
resource pg_get_result ([ resource $connection ] ) -
string pg_host ([ resource $connection ] ) - pg_host() returns the host name of the given PostgreSQL connection resource is connected to.
mixed pg_insert ( resource $connection , string $table_name , array $assoc_array [, int $options ] ) - pg_insert() inserts the values of assoc_array into the table specified by table_name.
string pg_last_error ([ resource $connection ] ) - pg_last_error() returns the last error message for a given connection.
string pg_last_notice ( resource $connection ) - pg_last_notice() returns the last notice message from the PostgreSQL server on the specified connection. The PostgreSQL server sends notice messages in several cases, for instance when creating a SERIAL column in a table.
string pg_last_oid ( resource $result ) - pg_last_oid() is used to retrieve the OID assigned to an inserted row.
bool pg_lo_close ( resource $large_object ) - pg_lo_close() closes a large object.
int pg_lo_create ([ resource $connection ] ) - pg_lo_create() creates a large object and returns the OID of the large object. 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).
bool pg_lo_export ( resource $connection , int $oid , string $pathname ) -
int pg_lo_import ( resource $connection , string $pathname ) -
resource pg_lo_open ( resource $connection , int $oid , string $mode ) - pg_lo_open() opens a large object in the database and returns large object resource so that it can be manipulated.
string pg_lo_read ( resource $large_object [, int $len ] ) -
int pg_lo_read_all ( resource $large_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.
bool pg_lo_seek ( resource $large_object , int $offset [, int $whence ] ) - pg_lo_seek() seeks a position within a large object resource.
int pg_lo_tell ( resource $large_object ) - pg_lo_tell() returns the current position (offset from the beginning) of a large object.
bool pg_lo_unlink ( resource $connection , int $oid ) - pg_lo_unlink() deletes a large object with the oid. Returns TRUE on success or FALSE on failure.
int pg_lo_write ( resource $large_object , string $data [, int $len ] ) - pg_lo_write() writes data into a large object at the current seek position.
array pg_meta_data ( resource $connection , string $table_name ) - pg_meta_data() returns table definition for table_name as an array.
int pg_num_fields ( resource $result ) - pg_num_fields() returns the number of fields (columns) in a PostgreSQL result resource.
int pg_num_rows ( resource $result ) - pg_num_rows() will return the number of rows in a PostgreSQL result resource.
string pg_options ([ resource $connection ] ) - pg_options() will return a string containing the options specified on the given PostgreSQL connection resource.
string pg_parameter_status ( resource $connection , string $param_name ) -
resource pg_pconnect ( string $connection_string [, int $connect_type ] ) - pg_pconnect() opens a connection to a PostgreSQL database. It returns a connection resource that is needed by other PostgreSQL functions.
bool pg_ping ([ resource $connection ] ) - pg_ping() pings a database connection and tries to reconnect it if it is broken.
int pg_port ([ resource $connection ] ) - pg_port() returns the port number that the given PostgreSQL connection resource is connected to.
resource pg_prepare ( resource $connection , string $stmtname , string $query ) -
bool pg_put_line ( string $data ) -
resource pg_query ( string $query ) -
resource pg_query_params ( resource $connection , string $query , array $params ) -
string pg_result_error ( resource $result ) - pg_result_error() returns any error message associated with the result resource.
string pg_result_error_field ( resource $result , int $fieldcode ) - pg_result_error_field() returns one of the detailed error message fields associated with result resource. It is only available against a PostgreSQL 7.4 or above server. The error field is specified by the fieldcode.
bool pg_result_seek ( resource $result , int $offset ) - pg_result_seek() sets the internal row offset in a result resource.
mixed pg_result_status ( resource $result [, int $type ] ) - pg_result_status() returns the status of a result resource, or the PostgreSQL command completion tag associated with the result
mixed pg_select ( resource $connection , string $table_name , array $assoc_array [, int $options ] ) - pg_select() selects records specified by assoc_array which has field=>value. For a successful query, it returns an array containing all records and fields that match the condition specified by assoc_array.
bool pg_send_execute ( resource $connection , string $stmtname , array $params ) - Sends a request to execute a prepared statement with given parameters, without waiting for the result(s).
bool pg_send_prepare ( resource $connection , string $stmtname , string $query ) - Sends a request to create a prepared statement with the given parameters, without waiting for completion.
bool pg_send_query ( resource $connection , string $query ) - pg_send_query() sends a query or queries asynchronously to the connection.
bool pg_send_query_params ( resource $connection , string $query , array $params ) - Submits a command and separate parameters to the server without waiting for the result(s).
int pg_set_client_encoding ( string $encoding ) -
int pg_set_error_verbosity ( resource $connection , int $verbosity ) -
bool pg_trace ( string $pathname [, string $mode [, resource $connection ]] ) - pg_trace() enables tracing of the PostgreSQL frontend/backend communication to a file. To fully understand the results, one needs to be familiar with the internals of PostgreSQL communication protocol.
int pg_transaction_status ( resource $connection ) - Returns the current in-transaction status of the server.
string pg_tty ([ resource $connection ] ) - pg_tty() returns the TTY name that server side debugging output is sent to on the given PostgreSQL connection resource.
string pg_unescape_bytea ( string $data ) - pg_unescape_bytea() unescapes PostgreSQL bytea data values. It returns the unescaped string, possibly containing binary data.
bool pg_untrace ([ resource $connection ] ) -
mixed pg_update ( resource $connection , string $table_name , array $data , array $condition [, int $options ] ) - pg_update() updates records that matches condition with data.
array pg_version ([ resource $connection ] ) - pg_version() returns an array with the client, protocol and server version. Protocol and server versions are only available if PHP was compiled with PostgreSQL 7.4 or later.