PHP Класс lithium\data\source\Result
Just a forward-only cursor is required, not necessarily a rolling cursor. Not all
data sources can support rolling cursors, that's why forward-only cursors have been
chosen here as the least common denominator for the abstraction.
Rolling cursors cannot be emulated from an underlying forward-only cursor in a
(memory) efficient way.
Result does not try to and will deliberately not keep
already yielded results in an internal cache.
To allow full (back and forth) iteration over the yielded results, a wrapping class
(i.e.
Collection) may keep such a cache while draining the
Result from outside.
Because of these characteristics an instance of
Result may be used only once.
After draining the result it cannot be rewinded or reset. This is similar to the
behavior of the
NoRewindIterator, where rewind calls have no effect.
The first result will be eager loaded from the cursor, as it is expected the
result will be used at least once.
The class also provides a mechanism which buffers results when peeking for next ones. The
buffered results will then be used when continuing to iterate over the result object.
Показать файл
Открыть проект
Примеры использования класса
Защищенные свойства (Protected)
Открытые методы
Метод |
Описание |
|
__destruct ( ) : void |
Destructor. |
|
close ( ) : void |
Close the resource. |
|
current ( ) : array |
Contains the current result. |
|
key ( ) : integer | null |
Returns the current key position on the result. |
|
next ( ) : mixed |
Fetches the next element from the resource. |
|
peek ( ) : mixed |
Peeks at the next element in the resource without advancing Result's cursor. |
|
resource ( ) : object | resource |
Returns the used resource. |
|
rewind ( ) : void |
Noop to fulfill the Iterator interface. Result is forward-only. |
|
valid ( ) : boolean |
Checks if current position is valid. |
|
Защищенные методы
Описание методов
__destruct()
публичный Метод
_fetch()
абстрактный защищенный Метод
Fetches the next result from the resource.
abstract protected _fetch ( ) : array | boolean | null |
Результат |
array | boolean | null |
Returns a key/value pair for the next result,
`null` if there is none, `false` if something bad happened. |
Initializer. Eager loads the first result.
current()
публичный Метод
Contains the current result.
public current ( ) : array |
Результат |
array |
The current result (or `null` if there is none). |
Returns the current key position on the result.
Fetches the next element from the resource.
public next ( ) : mixed |
Результат |
mixed |
The next result (or `null` if there is none). |
Peeks at the next element in the resource without advancing Result's cursor.
public peek ( ) : mixed |
Результат |
mixed |
The next result (or `null` if there is none). |
resource()
публичный Метод
Returns the used resource.
Noop to fulfill the Iterator interface. Result is forward-only.
Checks if current position is valid.
Описание свойств
$_autoConfig защищенное свойство
protected array $_autoConfig |
Результат |
array |
|
$_buffer защищенное свойство
Buffer results of query before returning / iterating. Allows consumers to 'peek' at results.
protected array $_buffer |
Результат |
array |
|
$_current защищенное свойство
Contains the current element of the result set.
protected mixed $_current |
Результат |
mixed |
|
$_iterator защищенное свойство
The current position of the iterator.
protected int $_iterator |
Результат |
integer |
|
$_key защищенное свойство
Key of the current result.
$_resource защищенное свойство
protected object|resource|null $_resource |
Результат |
object | resource | null |
|
$_valid защищенное свойство
Indicates whether the current position is valid or not.
protected bool $_valid |
Результат |
boolean |
|