629Chapter 34PostgreSQLon (Web hosting billing) characters to cartoonfan; GRANT SELECT, INSERT,

629Chapter 34PostgreSQLon characters to cartoonfan; GRANT SELECT, INSERT, UPDATE, DELETEon cartoons_id_seq to cartoonfan; Note that we must issue this command at the table level. For security reasons, the wildcardcharacter does not function in this context. The last command given is necessary for theserialfield type we selected in the cartoons table. PHP and PostgreSQLTable 34-1 itemizes the PHP functions for working with PostgreSQL databases. There aremany more functions than we can possibly elaborate on here. Many of them will make senseonly after you have gained more familiarity with Postgres. Also, many of the function namesfor Postgres changed with PHP version 4.2. Because this is a PHP5 book, we re going to con- centrate on the new names rather than the old. Table 34-1: Common PostgreSQL Functions in PHPFunctionBehaviorpg_connect()andTakes a single connection string as an argument, enumerating pg_pconnect()connection parameters such as host, database, port, user and password. pg_pconnect()is the persistent version. Returns a connection resource. See the listings below for usage examples. pg_query()This is the standard pass-through mechanism for sending basic SQL to theserver. In earlier versions, it was called pg_exec(), but this name hasbeen deprecated. Although optional, pg_query()likes to see aconnection resource, followed by a comma before the actual SQL. pg_fetch_row()Each of these functions takes at least a query-result resource as an pg_fetch_assoc()argument and returns varying results depending on the function chosen pg_fetch_array()and how it is called. Each of these except pg_fetch_all()used to pg_fetch_object()require a counter argument if you wished to iterate through the returned pg_fetch_result()rows. This argument is still available but is not necessary. These functions pg_fetch_all()differ primarily in the results they return, which in the same order as theyare listed are: 1) a numerically indexed array starting at an offset of 0; 2) an associative array with field names as indices; 3) returns both a numericand an associative array; 4) returns the rows and values in objectnotation; 5) returns a specific row and column offset; and 6) returns amultidimensional array of the entire result set. pg_affected_rows()Returns the number of tuples (rows) affected by an INSERT, UPDATE, orDELETEquery. pg_free_result()Frees the memory used by a query result. pg_num_fields()Returns the number of fields in a query result. Use with SELECTstatements. pg_num_rows()Returns the number of rows in a query result. Use with SELECTstatements. pg_close()Closes the PostgreSQL Connection. Takes a connection resource as anargument.
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

Leave a Reply