
Public Member Functions | |
| __construct ($cookie, $link) | |
| Creates a new DBResult object. | |
| __destruct () | |
| Cleans up this result object. | |
| free () | |
| Frees MySQL's internal result set object. | |
| getInsertId () | |
| Retrieves primary key for newly inserted rows. | |
| getRow ($n) | |
| Retrieves a particular row in the result set. | |
| nextRow () | |
| Retrieves next row in result set. | |
| numRows () | |
| Retrieves the number of rows in the result set. | |
| reset () | |
| Resets current row to the first row in the result set. | |
| seek ($n) | |
| Sets the current row to the specified row index. | |
| toArray () | |
| Converts entire result set to array. | |
An object of this class is returned by DBI2::select() and DBI2::query(). It contains methods that allow one to grab all or parts of the results returned by a SELECT query. In the former case, it behaves like the old DBI2 and a giant array is generated (with the toArray() method). In the later case, you can ask about specific rows, or iterate row by row. This results in less overhead as giant arrays do not need to be generated or duplicated.
Definition at line 15 of file DBI2.php5.
| DBResult::__construct | ( | $ | cookie, | |
| $ | link | |||
| ) |
Creates a new DBResult object.
You should not create DBResult objects directly. They will be returned from DBI2 from methods like select() and query(). The documentation provided here is only for completeness.
| $cookie | [resource]: result cookie returned from mysql_query() | |
| $link | [resource]: MySQL connection link |
| DBResult::__destruct | ( | ) |
Cleans up this result object.
For internal use only.
The result object needs to be cleaned up because it holds on to a MySQL result cookie, which must be freed. We let PHP automatically garbage collect this object and thus trigger the free operation.
Definition at line 44 of file DBI2.php5.
References free().
| DBResult::free | ( | ) |
Frees MySQL's internal result set object.
MySQL doesn't automatically clean up result cookies. This method does that, so that the result set objects that MySQL uses don't stay in memory forever. This method will be called automatically by the destructor of this class. The destructor will not be called if there are still references to the DBResult object, so be careful when passing around references to DBResult objects.
Definition at line 243 of file DBI2.php5.
Referenced by __destruct().
| DBResult::getInsertId | ( | ) |
Retrieves primary key for newly inserted rows.
When a new row is inserted and it has an auto-increment field as a primary key, MySQL generates a new ID for that row automatically and this ID can be retrieved using this method. This method essentially wraps mysql_insert_id().
Definition at line 57 of file DBI2.php5.
References SObject::setError().
| DBResult::getRow | ( | $ | n | ) |
Retrieves a particular row in the result set.
This method takes a row number, starting from zero, and returns the contents of that row, using mysql_fetch_assoc(). The current row is set to be the given row number and so calls to nextRow() will get rows starting after the given row. That is, a call to nextRow() after getRow() will return the row after the one just retrieved with getRow().
| $n | [int]: numeric index of the row to retrieve, starting from zero |
Definition at line 179 of file DBI2.php5.
References SObject::setError().
| DBResult::nextRow | ( | ) |
Retrieves next row in result set.
When called for the first time, this method will retrieve the first row in the result set using mysql_fetch_assoc(), which returns an associative array for the row in the result set. Subsequent calls will retrieve subsequent rows. If there are no more rows, false is returned. If there was an error, null is returned and an error is set on this object. You can reset the current row with reset(), or seek to a particular row with getRow().
Definition at line 101 of file DBI2.php5.
References numRows(), and SObject::setError().
| DBResult::numRows | ( | ) |
Retrieves the number of rows in the result set.
Definition at line 72 of file DBI2.php5.
References SObject::setError().
Referenced by nextRow().
| DBResult::reset | ( | ) |
Resets current row to the first row in the result set.
After calling this method, a call to nextRow() will return the first row of the set and continue from there. No data is lost in this operation.
Definition at line 127 of file DBI2.php5.
References SObject::setError().
| DBResult::seek | ( | $ | n | ) |
Sets the current row to the specified row index.
The row index is zero based. A call to nextRow() after this method will return the contents of the row specified by the parameter to this method. As such, seek(n) followed by nextRow() is exactly equivalent to getRow(n).
| $n | [int]: row index to seek to, zero-based |
Definition at line 152 of file DBI2.php5.
References SObject::setError().
| DBResult::toArray | ( | ) |
Converts entire result set to array.
The array is two levels deep. There is one entry in the top-level array for each row in the result set. And each entry is an associative array containing the data for each row, keyed by field name. The top-level array is keyed by row number, starting at zero (i.e., it is a plain, non-associative array). Multiple calls to this method will not generate the array multiple times, rather, the array created on the first call will be returned in subsequent calls. Furthermore, if the current row, as selected by nextRow() or getRow() will not be disturbed by a call to this method.
Definition at line 207 of file DBI2.php5.
References SObject::setError().
1.5.6