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.
khosb/includes/kohana/modules/database/classes/Kohana/Database/Result/Cached.php

52 lines
1.1 KiB
PHP
Raw Normal View History

2012-11-09 12:18:50 +00:00
<?php defined('SYSPATH') OR die('No direct script access.');
2010-08-21 04:43:03 +00:00
/**
2011-05-13 06:00:25 +00:00
* Object used for caching the results of select queries. See [Results](/database/results#select-cached) for usage and examples.
2010-08-21 04:43:03 +00:00
*
* @package Kohana/Database
* @category Query/Result
* @author Kohana Team
* @copyright (c) 2009 Kohana Team
* @license http://kohanaphp.com/license
*/
class Kohana_Database_Result_Cached extends Database_Result {
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);
}
public function __destruct()
{
// Cached results do not use resources
}
public function cached()
{
return $this;
}
public function seek($offset)
{
if ($this->offsetExists($offset))
{
$this->_current_row = $offset;
return TRUE;
}
else
{
return FALSE;
}
}
public function current()
{
// Return an array of the row
2011-05-13 06:00:25 +00:00
return $this->valid() ? $this->_result[$this->_current_row] : NULL;
2010-08-21 04:43:03 +00:00
}
} // End Database_Result_Cached