diff --git a/reference/pgsql/functions/pg-convert.xml b/reference/pgsql/functions/pg-convert.xml index 3fbde0fe80..1d065e033a 100644 --- a/reference/pgsql/functions/pg-convert.xml +++ b/reference/pgsql/functions/pg-convert.xml @@ -1,5 +1,5 @@ - + @@ -88,7 +88,31 @@ An array of converted values, or &false; on error. - + + + &reftitle.examples; + + + <function>pg_convert</function> example + + 'Joe Thackery', + 'year' => 2005, + 'title' => 'My Life, by Joe Thackery' + ); + + $vals = pg_convert($dbconn, 'authors', $tmp); +?> +]]> + + + + + &reftitle.seealso; diff --git a/reference/pgsql/functions/pg-field-prtlen.xml b/reference/pgsql/functions/pg-field-prtlen.xml index 6c145a84d4..db194b47af 100644 --- a/reference/pgsql/functions/pg-field-prtlen.xml +++ b/reference/pgsql/functions/pg-field-prtlen.xml @@ -1,5 +1,5 @@ - + @@ -75,7 +75,56 @@ The field printed length, or &false; on error. - + + + &reftitle.examples; + + + Getting information about fields + + +]]> + + &example.outputs; + + + + + + + &reftitle.seealso; diff --git a/reference/pgsql/functions/pg-set-client-encoding.xml b/reference/pgsql/functions/pg-set-client-encoding.xml index 0c85cfec64..084d88116a 100644 --- a/reference/pgsql/functions/pg-set-client-encoding.xml +++ b/reference/pgsql/functions/pg-set-client-encoding.xml @@ -1,5 +1,5 @@ - + @@ -77,7 +77,44 @@ Returns 0 on success or -1 on error. + + + &reftitle.examples; + + + <function>pg_set_client_encoding</function> example + +\n"; +} +?> +]]> + + + + &reftitle.seealso; diff --git a/reference/pgsql/reference.xml b/reference/pgsql/reference.xml index 1db183a8cb..c6c99993aa 100644 --- a/reference/pgsql/reference.xml +++ b/reference/pgsql/reference.xml @@ -1,5 +1,5 @@ - + @@ -26,7 +26,7 @@ To use PostgreSQL support, you need PostgreSQL 6.5 or later, PostgreSQL 8.0 or later to enable all PostgreSQL module - features. PostgreSQL supports many character encoding including + features. PostgreSQL supports many character encodings including multibyte character encoding. The current version and more information about PostgreSQL is available at &url.pgsql; and @@ -38,282 +38,95 @@ &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 - - - -
+
+ &reftitle.resources; - 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. + There are two resource types used in the PostgreSQL module. The first one + is the link identifier for a database connection, the second a resource + which holds the result of a query. - - - 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.notes; + + + Not all functions are supported by all builds. It depends on your + libpq (The PostgreSQL C client library) version and how libpq is + compiled. If PHP PostgreSQL extensions are missing, then it is because + your libpq version does not support them. + + + + + Most PostgreSQL functions accept connection as + the first optional parameter. If it is not provided, the last opened + connection is used. If it doesn't exist, functions return &false;. + + + + + PostgreSQL automatically folds all identifiers (e.g. table/column names) + to lower-case values at object creation time and at query time. + To force the use of mixed or upper case identifiers, you must escape + the identifier using double quotes (""). + + + + + PostgreSQL does not have special commands for fetching database schema + information (eg. all the tables in the current database). Instead, there + is a standard schema named information_schema in + PostgreSQL 7.4 and above containing + system views with all the necessary information, in an easily + queryable form. See the PostgreSQL Documentation + for full details. + + +
+
&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 - + + This simple example shows how to connect, execute a query, print + resulting rows and disconnect from a PostgreSQL database. + + PostgreSQL extension overview example + \n"; +while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) { + echo "\t\n"; + foreach ($line as $col_value) { + echo "\t\t$col_value\n"; + } + echo "\t\n"; +} +echo "\n"; + +// Free resultset +pg_free_result($result); + +// Closing connection +pg_close($link); ?> ]]> - - - You should not close the connection to the PostgreSQL server - before closing the large object. - -
+ + + +
&reference.pgsql.functions;