This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
lnldap/classes/Kohana/Database/LDAP/Result/Cached.php
2013-07-13 22:42:02 +10:00

70 lines
1.6 KiB
PHP

<?php defined('SYSPATH') OR die('No direct script access.');
/**
* Object used for caching the results of select queries. See [Results](/database/results#select-cached) for usage and examples.
*
* @package Kohana/LDAP
* @category Query/Result
* @author Deon George
* @copyright (c) 2013 phpLDAPadmin Development Team
* @license http://dev.phpldapadmin.org/license.html
*/
class Kohana_Database_LDAP_Result_Cached extends Database_Result_Cached {
public function __construct(array $result, $sql, $as_object = NULL)
{
parent::__construct($result, $sql, $as_object);
// Find the number of rows in the result
$this->_total_rows = count($result);
$this->_current_row = key($result);
}
public function __destruct() {
// Cached results do not use resources
}
public function cached() {
return $this;
}
public function current() {
// Return an array of the row
return $this->valid() ? $this->_result[$this->_current_row] : NULL;
}
public function key() {
return $this->_current_row;
}
public function next() {
next($this->_result);
$this->_current_row = key($this->_result);
return $this;
}
public function offsetExists($offset) {
return isset($this->_result[$offset]);
}
public function rewind() {
// We dont index by numbers, so we can just return
reset($this->_result);
$this->_current_row = key($this->_result);
return $this;
}
public function seek($offset) {
if (isset($this->_result[$offset])) {
$this->_current_row = $offset;
return TRUE;
} else {
return FALSE;
}
}
} // End Database_LDAP_Result_Cached