README 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. ==== About This Module ===
  2. PostgreSQL module provides access to PostgreSQL server from
  3. PHP script. This module uses PostgreSQL C client lib called libpq.
  4. It is important that you use libpq that is later than backend
  5. (PostgreSQL Server) version. Otherwise, you may experience
  6. strange problems.
  7. Please send e-mail to yohgaki@php.net if you have comments for
  8. pgsql module. I appreciate your feedback.
  9. ==== API Change ===
  10. Older PHP than 4.2.0, pg_loimport()/pg_loexport() connection
  11. parameter as last parameter, not like other functions. From 4.2.0,
  12. connection parameter became 1st parameter. Old syntax is preserved,
  13. but it will raise NOTICE error message.
  14. pg_connect()/pg_pconnect() has obsolete multi parameter syntax.
  15. This syntax will be deleted in 4.3.0 or later.
  16. Omitting connectin parameter is NOT recommended. Connection
  17. parameter may be required for future PHP version. Specify connection
  18. always if you don't want to rewrite code when it is changed.
  19. ==== Function Name Change ====
  20. Function names are going to be changed to confirm coding
  21. standard. MySQL module has been done this already. Function names will
  22. be changed as follows.
  23. pg_errormessage -> pg_error_message
  24. pg_cmdtuples -> pg_affected_rows
  25. pg_fieldnum -> pg_field_num
  26. and so on. Except pg_cmdtuples, under scores '_' will be added to
  27. names.
  28. Older names will become aliases of new functions for backward
  29. compatibility.
  30. Manual will be updated when this change is committed to CVS source.
  31. ==== Configure Option Notes ====
  32. You cannot specify PostgreSQL source directly to build PostgreSQL
  33. module with specific version. You need to install PostgreSQL
  34. somewhere in your system to build PHP with PostgreSQL support.
  35. ==== Note For PostgreSQL 7.2 ====
  36. I've tested up to 7.2.2.
  37. ==== TODO List ===
  38. Make pg_convert() smater.
  39. - Better regex
  40. - User defiend type support
  41. Support async connection.
  42. ==== Experimental Functions =====
  43. WARNING: API/behavior may be changed without notice.
  44. Async query can improve application performance
  45. *significantly*. Please test and report any failure to
  46. yohgaki@php.net
  47. There are some cases that async functions blocks process. Even if
  48. process was blocked, functions work as expected. (except it blocks
  49. process) These are cases that process is blocked. Refer to libpq
  50. manual for details. Followings are common cases that async functions
  51. are blocked.
  52. - If libpq is compile with USE_SSL, some async functions are
  53. blocked.
  54. - If libpq under Win32 is *NOT* compiled with
  55. WIN32_NON_BLOCKING_CONNECTIONS, non-blocking connection will block.
  56. Async function may also block if you have not retrive result and
  57. send or execute query. If there is result left on connection,
  58. pg_send_query() will block until last query is completed.
  59. Garbages are cleaned when resource is cleaned up. There is no need to
  60. clean up query result if it is not needed.
  61. Please refer to libpq manual or source for details.
  62. These functions are *NOT* supposed to be documented, yet.
  63. API may be changed.
  64. NOTE: These functions are added in PHP 4.2.0 unless they are mentioned.
  65. -------------------------------------------------------------------
  66. bool pg_send_query(resource connection, string query)
  67. Sends async query to backend. Result may be retrieved with
  68. pg_get_result(). It does not accept multiple query, but it accepts
  69. multiple queries at once. Each result may be retrieved separately by
  70. pg_get_result().
  71. --------------------------------------------------------------------
  72. bool pg_cancel_query(resource connection)
  73. Cancels currently executing async query already sent to PostgreSQL
  74. server. This function is useful when user request time consuming query
  75. to server. It cannot cancel query executed by pg_exec(), since
  76. pg_exec() is a blocking function.
  77. --------------------------------------------------------------------
  78. resource pg_get_result(resource conn)
  79. Gets pgsql query result resource. Returned value can be fed to
  80. pg_result()/pg_fetch_*(). pg_get_result() may block if result is not
  81. ready to be retrived. Use pg_is_busy() to check result is ready to be
  82. retrieved or not. If multiple query is sent to backend, it may be
  83. retrieved one by one using pg_get_result(). If there is no result left
  84. in connection, it returns false.
  85. --------------------------------------------------------------------
  86. bool pg_connection_busy(resource connection)
  87. Returns connections is executing query or not.
  88. --------------------------------------------------------------------
  89. int pg_connection_status(resource connection)
  90. Gets connection status. It returns PGSQL_CONNECTION_OK or
  91. PGSQL_CONNECTION_BAD.
  92. --------------------------------------------------------------------
  93. bool pg_connection_reset(resource connection)
  94. Resets communication port to Postgresql server using the same
  95. connection parameter. It's useful for error recovery.
  96. --------------------------------------------------------------------
  97. string pg_result_error(resource result)
  98. Get error message associated with result
  99. --------------------------------------------------------------------
  100. int pg_result_status(resource result)
  101. Get status of query result
  102. --------------------------------------------------------------------
  103. Copy functions
  104. --------------------------------------------------------------------
  105. mixed pg_copy_to(int connection_id, string table_name,
  106. [, string delim [, string null_as]])
  107. nt pg_copy_from(int connection_id, string table_name, array rows
  108. [, string delim [, string null_as]])
  109. --------------------------------------------------------------------
  110. Utility functions
  111. --------------------------------------------------------------------
  112. string pg_escape_string(string data)
  113. Escape string or binary for SQL statemen (7.2 or later)
  114. string pg_escape_bytea(string data)
  115. Escape string or binary for SQL statement (7.2 or later)
  116. --------------------------------------------------------------------
  117. Large Object Functions
  118. --------------------------------------------------------------------
  119. int pg_lo_tell(resource large_object)
  120. Returns current position of large object
  121. --------------------------------------------------------------------
  122. bool pg_lo_lseek(resource large_object, int offset[, int whence])
  123. Seeks position of large object
  124. --------------------------------------------------------------------
  125. Notice message function
  126. --------------------------------------------------------------------
  127. string pg_last_notice(resource connection)
  128. Returns the last notice set by the backend
  129. This function is fully implemed in only in current CVS version.
  130. PHP 4.3.0 supposed to included fully implemented version.
  131. NOTE: Added in PHP 4.0.6, but there is bug in notice message handling
  132. in PHP 4.0.6. Do no use 4.0.6 with pgsql module!!
  133. --------------------------------------------------------------------
  134. Utility functions (for PHP 4.3.0)
  135. --------------------------------------------------------------------
  136. array pg_metadata(resource db, string table)
  137. Get metadata
  138. --------------------------------------------------------------------
  139. array pg_convert(resource db, string table, array values)
  140. Check and convert values for PostgreSQL SQL statement
  141. --------------------------------------------------------------------
  142. bool pg_insert(resource db, string table, array values[, bool convert[, bool async]])
  143. Insert values (filed=>value) to table
  144. --------------------------------------------------------------------
  145. bool pg_update(resource db, string table, array fields, array ids[, bool convert[, bool async]])
  146. Update table using values (field=>value) and ids (id=>value)
  147. --------------------------------------------------------------------
  148. bool pg_delete(resource db, string table, array ids[, bool convert[, bool async]])
  149. Delete records has ids (id=>value)
  150. --------------------------------------------------------------------
  151. array pg_select(resource db, string table, array ids[, bool convert])
  152. Select records that has ids (id=>value)
  153. --------------------------------------------------------------------
  154. array pg_get_notify([resource db[, notify]])
  155. Get notify message on the connection
  156. --------------------------------------------------------------------
  157. string pg_unescape_bytea(string bytea_data)
  158. Unescape bytea field data
  159. --------------------------------------------------------------------
  160. bool pg_ping(resource db)
  161. ping database connection and try to reset connection if it's
  162. broken
  163. -------------------------------------------------------------------
  164. Again, experimental functions are subject to be changed without
  165. notice.