30 private $start = null;
37 private $limit = null;
43 private $query = null;
50 private $bufferSize = 30;
56 private $buffer = null;
64 private $bufferStartPos = null;
70 private $currPos = null;
90 $this->start = @$query[
'-skip'] ? intval($query[
'-skip']):0;
91 $this->limit = @$query[
'-limit'] ? intval($query[
'-limit']):null;
92 $this->query = $query;
93 $this->bufferSize = $bufferSize;
95 $this->bufferStartPos = null;
96 $this->currPos = $this->start;
98 if ( isset($this->limit) and $this->limit < $this->bufferSize ) $this->bufferSize = $this->limit;
105 $this->buffer = null;
113 $this->currPos = $this->start;
115 if ( !isset($this->bufferStartPos) ){
118 }
else if ( $this->bufferStartPos > $this->start ){
121 $this->buffer = null;
122 $this->bufferStartPos = null;
133 private function loadBuffer(){
134 if ( $this->currPos >= $this->bufferStartPos + $this->bufferSize ){
135 $this->bufferStartPos += $this->bufferSize;
136 }
else if ( !isset($this->bufferStartPos) ){
137 $this->bufferStartPos = $this->start;
142 $q[
'-skip'] = $this->bufferStartPos;
143 $q[
'-limit'] = $this->bufferSize;
144 if ( isset($this->limit) ){
145 $q[
'-limit'] = min($this->bufferSize, $this->start+$this->limit-$this->bufferStartPos);
147 if ( $q[
'-limit'] > 0 ){
148 $this->buffer = df_get_records_array($q[
'-table'], $q, $q[
'-skip'], $q[
'-limit'], $this->previewRecords);
150 $this->buffer = array();
161 return $this->buffer[$this->currPos-$this->bufferStartPos];
169 return $this->currPos;
184 return isset($this->buffer[$this->currPos-$this->bufferStartPos]);