Constructor. When creating an instance, you may optionally supply a query string.
$db = new DB_Sql_Subclass("select * from mytable");)query_string is a SQL statement that is sent to the database. After sending the statement, Error and Errno are updated. If the query is syntactically incorrect (no valid result id is being produced), halt() is called with a meaningful error message.
If there is no active link to the database, a pconnect() is made using the information from the Host, Database, User and Password instance variables.
Returns the result of the query() statement, which is guaranteed to be a valid result id (or false, if Halt_On_Error isn't "yes").
next_record() advances the cursor through the current query result and updates the Record, Row, Errno and Error instance variables.
Returns true, if there is a new result record. Returns false, if done with the current result set. If Auto_Free is true, free_result() is called automatically before false is returned.
Returns the number of rows returned by the current SELECT query.
Note: This information is not available in all database interfaces. Some of the more advanced databases begin to return query results asynchronously while the backend is still appending result rows. In such environments the complete size of the result set is never known.
You should duplicate your WHERE clause of the query in such environments and ask for the COUNT(*). This will be less inefficient as it seems as the query path and query result have been cached by the database.
This function is called by halt() and will actually print the database error message. You may override this method in your subclass of DB_Sql and format the error message to be consistent with the layout of the rest of your application. You may also add additional error handling such as informing the application operator by mail that a database error has occured.
Positions the Row pointer within the result set. Useful for reading the same result set twice or otherwise jumping around within the result. $pos is not checked in any way for validity.
Note: If Auto_Free is true, seek() may not be useable, because the result set has already been freed when next_record() when behind the last record of the result set.
Note: Not all database interfaces provide a cursor that is capable of seeking. This function will be unavailable in such environments.
In some DB interfaces locks one or more tables using the mode(s) specified. $table can be a single table, a comma separated list of tables, or an array of mode/table (or table list) pairs.
This function will return the current link ID, as returned by the pconnect() executed internally by the database class. You should not need this information.
This function will return the current result ID, as returned by the query() executed internally by the database class. You should not need this information.
$table is a SQL table name in the current database. The function returns an array of hashes indexed on the (0 based) column number of $table. Each hash is indexed by table (table of which this column is part of), name (name of this column), type (column data type), len (column width) and flags (database specific column flags, if applicable) with one row per table column. Each row describes a column in your table.
The data returned by metadata() is suitable for passing it to the Table class. If you specify the full parameter, an additional column meta is added, which is indexed by field name and returns the field number of that name. Also, a column num_fields is added, containing the width of the table.
If $table is omitted, the function returns metadata on the result of the last executed query. Note: This is currently implemented only for the MySQL interface. You are encouraged to implement this feature for other interfaces.
Used internally to generate a Link_ID, if necessary. Link creation is implicit, there is no need to call connect() manually, ever.