PHP 클래스 ElggBatch, Elgg

This is usually used with elgg_get_entities() and friends, elgg_get_annotations(), and elgg_get_metadata(). If you pass a valid PHP callback, all results will be run through that callback. You can still foreach() through the result set after. Valid PHP callbacks can be a string, an array, or a closure. {@link http://php.net/manual/en/language.pseudo-types.php} The callback function must accept 3 arguments: an entity, the getter used, and the options used. Results from the callback are stored in callbackResult. If the callback returns only booleans, callbackResults will be the combined result of all calls. If the callback returns anything else, callbackresult will be an indexed array of whatever the callback returns. If returning error handling information, you should include enough information to determine which result you're referring to. Don't combine returning bools and returning something else. Note that returning false will not stop the foreach.
부터: 1.8
상속: implements Iterator
파일 보기 프로젝트 열기: elgg/elgg 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$callbackResult mixed The result of running all entities through the callback function.

공개 메소드들

메소드 설명
__construct ( string $getter, array $options, mixed $callback = null, integer $chunk_size = 25, boolean $inc_offset = true ) Batches operations on any elgg_get_*() or compatible function that supports an options array.
count ( ) : integer Count the total results available at this moment.
current ( )
key ( )
next ( )
reportIncompleteEntity ( stdClass $row ) Tell the process that an entity was incomplete during a fetch
rewind ( )
setIncrementOffset ( boolean $increment = true ) : void Increment the offset from the original options array? Setting to false is required for callbacks that delete rows.
valid ( )

비공개 메소드들

메소드 설명
getNextResultsChunk ( ) : boolean Fetches the next chunk of results

메소드 상세

__construct() 공개 메소드

Instead of returning all objects in memory, it goes through $chunk_size objects, then requests more from the server. This avoids OOM errors.
public __construct ( string $getter, array $options, mixed $callback = null, integer $chunk_size = 25, boolean $inc_offset = true )
$getter string The function used to get objects. Usually an elgg_get_*() function, but can be any valid PHP callback.
$options array The options array to pass to the getter function. If limit is not set, 10 is used as the default. In most cases that is not what you want.
$callback mixed An optional callback function that all results will be passed to upon load. The callback needs to accept $result, $getter, $options.
$chunk_size integer The number of entities to pull in before requesting more. You have to balance this between running out of memory in PHP and hitting the db server too often.
$inc_offset boolean Increment the offset on each fetch. This must be false for callbacks that delete rows. You can set this after the object is created with {@link \ElggBatch::setIncrementOffset()}.

count() 공개 메소드

As this performs a separate query, the count returned may not match the number of results you can fetch via iteration on a very active DB.
또한 보기: Countable::count()
public count ( ) : integer
리턴 integer

current() 공개 메소드

public current ( )

key() 공개 메소드

public key ( )

next() 공개 메소드

public next ( )

reportIncompleteEntity() 공개 메소드

Tell the process that an entity was incomplete during a fetch
public reportIncompleteEntity ( stdClass $row )
$row stdClass

rewind() 공개 메소드

public rewind ( )

setIncrementOffset() 공개 메소드

Increment the offset from the original options array? Setting to false is required for callbacks that delete rows.
public setIncrementOffset ( boolean $increment = true ) : void
$increment boolean Set to false when deleting data
리턴 void

valid() 공개 메소드

public valid ( )

프로퍼티 상세

$callbackResult 공개적으로 프로퍼티

The result of running all entities through the callback function.
public mixed $callbackResult
리턴 mixed