DB_common::setFetchMode()
Параметр
- integer $fetchmode
DB_FETCHMODE_ORDERED, DB_FETCHMODE_ASSOC or DB_FETCHMODE_OBJECT.
See the Examples section, below, for more information.
- string $object_class
This parameter is for use when $fetchmode is set to DB_FETCHMODE_OBJECT.
You can set this parameter to DB_row, which then causes the resulting data to populate a new instance of a DB_row object.
Throws
Таблица 35-1. Возможные значения PEAR_Error
Error code | Error message | Reason | Solution |
---|---|---|---|
NULL | invalid fetchmode mode | The given fetch mode does not exists or is not implement in your DB version. | Check writing of the argument and your used version of DB. |
Пример
Пример 35-1. DB_FETCHMODE_ORDERED (default) Causes ordered arrays to be returned. The order is taken from the select statement.
Output:
|
Пример 35-2. DB_FETCHMODE_ASSOC Makes associative arrays, with the column names as the array keys.
Output:
|
Пример 35-3. DB_FETCHMODE_OBJECT Returns objects with column names as properties.
Output:
|
Пример 35-4. DB_FETCHMODE_OBJECT and DB_row If setFetchMode()'s optional $object_class parameter is set to DB_row, DB_row objects are returned.
Output:
|
Пример 35-5. DB_FETCHMODE_OBJECT with your own object in PHP 4
Output:
|
Пример 35-6. DB_FETCHMODE_OBJECT with your own object in PHP 5
Output:
|
Пред. | Начало | След. |
DB_common::rollback() | Уровень выше | DB_common::setOption() |