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

79 lines
1.7 KiB
PHP
Raw Normal View History

2013-07-13 12:42:02 +00:00
<?php defined('SYSPATH') OR die('No direct script access.');
2013-08-16 02:21:17 +00:00
2013-07-13 12:42:02 +00:00
/**
* Object used for caching the results of select queries. See [Results](/database/results#select-cached) for usage and examples.
*
2014-02-11 00:26:11 +00:00
* @package Kohana/Database
2013-07-13 12:42:02 +00:00
* @category Query/Result
* @author Deon George
* @copyright (c) 2013 phpLDAPadmin Development Team
* @license http://dev.phpldapadmin.org/license.html
*/
2013-08-16 02:21:17 +00:00
abstract class Kohana_Database_LDAP_Result_Cached extends Database_Result_Cached {
2014-04-29 04:26:56 +00:00
protected $cache_key = NULL;
2013-07-13 12:42:02 +00:00
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
}
2014-04-29 04:26:56 +00:00
public function cache_key($key=NULL) {
if (is_null($key))
return $this->cache_key;
$this->cache_key = $key;
}
2013-07-13 12:42:02 +00:00
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
2013-08-16 02:21:17 +00:00
?>