The get*() methods in this interface will format values before returning them. Note that if they will return null if the database returned NULL. If the requested column does not exist than an exception (SQLException) will be thrown.
$rs = $conn->executeQuery("SELECT MAX(stamp) FROM event", ResultSet::FETCHMODE_NUM); $rs->next();
$max_stamp = $rs->getTimestamp(1, "d/m/Y H:i:s"); // $max_stamp will be date string or null if no MAX(stamp) was found
$max_stamp = $rs->getTimestamp("max(stamp)", "d/m/Y H:i:s"); // will THROW EXCEPTION, because the resultset was fetched using numeric indexing // SQLException: Invalid resultset column: max(stamp)
This class implements SPL IteratorAggregate, so you may iterate over the database results using foreach(): foreach($rs as $row) { print_r($row); // row is assoc array returned by getRow() }
Author Hans Lellelid <hans@xmpl.org>
Version
Revision
|
Index result set by field name. |
|
Index result set numerically. |
|
Get the PHP native resource for the result. Arguably this should not be part of the interface: i.e. every driver should implement it if they have a result resource, but conceivably drivers could be created that do not. For now every single driver does have a "dblink" resource property, and other classes (e.g. ResultSet) need this info in order to get correct native errors. We'll leave it in for now, as it helps with driver development, with the caveat that it could be removed from the interface at a later point. Returns resource Query result or NULL if not not applicable. Reimplemented in ResultSetCommon. |
|
Sets the fetchmode used to retrieve results. Changing fetchmodes mid-result retrieval is supported (haven't encountered any drivers that don't support that yet).
Returns void Reimplemented in ResultSetCommon. |
|
Gets the fetchmode used to retrieve results. Returns int ResultSet::FETCHMODE_NUM or ResultSet::FETCHMODE_ASSOC (default). Reimplemented in ResultSetCommon. |
|
Whether assoc result keys get left alone -- as opposed to converted to lowercase. If the case change stuff goes back to being more complicated (allowing conver to upper, e.g.) then we'll add new methods but this method will always indicate whether any case conversions should be (or have been) performed at all. This defaults to true unless Creole::NO_ASSOC_LOWER flag has been passed to connection. This property is read-only since it must be set when connection is created. The reason for this behavior is some drivers (e.g. SQLite) do the case conversions internally based on a PHP ini value; it would not be possible to change the behavior from the ResultSet (since query has already been executed). Returns boolean Reimplemented in ResultSetCommon. |
|
Moves the internal cursor to the next position and fetches the row at that position.
Returns boolean Reimplemented in MSSQLResultSet, MySQLResultSet, OCI8ResultSet, and PgSQLResultSet. |
|
Moves the internal cursor to the previous position and fetches the row at that position.
Returns boolean
Reimplemented in ResultSetCommon. |
|
Moves the cursor a relative number of rows, either positive or negative and fetches the row at that position. Attempting to move beyond the first/last row in the result set positions the cursor before/after the first/last row and issues a Warning. Calling relative(0) is valid, but does not change the cursor position.
Returns boolean
Reimplemented in ResultSetCommon. |
|
Moves the cursor to an absolute cursor position and fetches the row at that position. Attempting to move beyond the first/last row in the result set positions the cursor before/after the first/last row and issues a Warning.
Returns boolean
Reimplemented in ResultSetCommon. |
|
Moves cursor position WITHOUT FETCHING ROW AT THAT POSITION. Generally this method is for internal driver stuff (e.g. other methods like absolute() or relative() might call this and then call next() to get the row). This method is public to facilitate more advanced ResultSet scrolling tools -- e.g. cleaner implimentation of ResultSetIterator. Some drivers will emulate seek() and not allow reverse seek (Oracle). Seek is 0-based, but seek() is only for moving to the space _before_ the record that you want to read. I.e. if you seek(0) and then call next() you will have the first row (i.e. same as calling first() or absolute(1)).
IMPORTANT: You cannot rely on the return value of this method to know whether a given record exists for reading. In some cases seek() will correctly return
Returns boolean true on success, false if unable to seek to specified record.
Reimplemented in MSSQLResultSet, MySQLResultSet, OCI8ResultSet, and PgSQLResultSet. |
|
Move cursor to beginning of recordset. Returns boolean
Reimplemented in ResultSetCommon. |
|
Move cursor to end of recordset. Returns boolean SQLException - if unable to move to last position
Reimplemented in ResultSetCommon. |
|
Sets cursort to before first record. This does not actually seek(), but simply sets cursor pos to 0. This is useful for inserting a record before the first in the set, etc. Returns void Reimplemented in ResultSetCommon. |
|
Sets cursort to after the last record. This does not actually seek(), but simply sets the cursor pos to last + 1. This [will be] useful for inserting a record after the last in the set, when/if Creole supports updateable ResultSets.
Returns TRUE on success, SQLException on error Reimplemented in ResultSetCommon. |
|
Checks whether cursor is after the last record. Returns boolean
Reimplemented in ResultSetCommon. |
|
Checks whether cursor is before the first record. Returns boolean
Reimplemented in ResultSetCommon. |
|
Returns the current cursor position. Cursor positions start at 0, but as soon as first row is fetched cursor position is 1. (so first row is 1) Returns int Reimplemented in ResultSetCommon. |
|
Gets current fields (assoc array). Returns array Reimplemented in ResultSetCommon. |
|
Get the number of rows in a result set. Returns int the number of rows
Reimplemented in MSSQLResultSet, MySQLResultSet, OCI8ResultSet, and PgSQLResultSet. |
|
Frees the resources allocated for this result set. Also empties any internal field array so that any calls to get() method on closed ResultSet will result in "Invalid column" SQLException. Returns void Reimplemented in MSSQLResultSet, MySQLResultSet, OCI8ResultSet, and PgSQLResultSet. |
|
A generic get method returns unformatted (=string) value. This returns the raw results from the database. Usually this will be a string, but some drivers also can return objects (lob descriptors, etc) in certain cases.
Returns mixed Usually expect a string.
Reimplemented in ResultSetCommon. |
|
Reads a column as an array. The value of the column is unserialized & returned as an array. The generic case of this function is very PHP-specific. Other drivers (e.g. Postgres) will format values into their native array format.
Returns array value or null if database returned null.
Reimplemented in ResultSetCommon, and PgSQLResultSet. |
|
Returns value translated to boolean. Default is to map 0 => false, 1 => true, but some database drivers may override this behavior.
Returns boolean value or null if database returned null.
Reimplemented in ResultSetCommon, and PgSQLResultSet. |
|
Returns Blob with contents of column value.
Returns Blob New Blob with data from column or null if database returned null.
Reimplemented in ResultSetCommon, and PgSQLResultSet. |
|
Returns Clob with contents of column value.
Returns Clob New Clob object with data from column or null if database returned null.
Reimplemented in ResultSetCommon. |
|
Return a formatted date. The default format for dates returned is preferred (in your locale, as specified using setlocale()) format w/o time (i.e. strftime("%x", $val)). Override this by specifying a format second parameter. You can also specify a date()-style formatter; if you do, make sure there are no "%" symbols in your format string.
Returns string formatted date or null if database returned null
Reimplemented in ResultSetCommon. |
|
Returns value cast as a float (in PHP this is same as double).
Returns float value or null if database returned null
Reimplemented in ResultSetCommon. |
|
Returns value cast as integer.
Returns int value or null if database returned null See also getInteger()
Reimplemented in ResultSetCommon. |
|
Returns value cast as string.
Returns string value or null if database returned null See also get()
Reimplemented in ResultSetCommon, and MySQLResultSet. |
|
Return a formatted time. The default format for times returned is preferred (in your locale, as specified using setlocale()) format w/o date (i.e. strftime("%X", $val)). Override this by specifying a format second parameter. You can also specify a date()-style formatter; if you do, make sure there are no "%" symbols in your format string.
Returns string Formatted time or null if database returned null
Reimplemented in ResultSetCommon. |
|
Return a formatted timestamp. The default format for timestamp is ISO standard YYYY-MM-DD HH:MM:SS (i.e. date('Y-m-d H:i:s', $val). Override this by specifying a format second parameter. You can also specify a strftime()-style formatter. Hint: if you want to get the unix timestamp use the "U" formatter string.
Returns string Formatted timestamp or null if database returned null
Reimplemented in ResultSetCommon, and MySQLResultSet. |
This file is part of the Creole[php4] library.
Copyright © 2004 Hans Lellelid |   |
Creole[php4] CVS
|