Created
March 4, 2009 13:28
-
-
Save shadowhand/73837 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$cache = array | |
( | |
15 => array('id' => 15, 'title' => 'United States', 'shortname' => 'USA'); | |
); | |
$data = Country_Model::cache($title, 'title'); | |
$data is now array('id' => 15, 'title' => 'United States', 'shortname' => 'USA'); | |
Country_Model::cache(15); | |
public function cache($search = NULL, $column = NULL) | |
{ | |
if ($search === NULL) | |
{ | |
// return all values | |
} | |
if ($column !== NULL) | |
{ | |
foreach ($this->cache as $values) | |
{ | |
if ($values[$column] === $search) | |
{ | |
return $values; | |
} | |
} | |
} | |
return $this->cache[$id]; | |
} | |
public function build_cache() | |
{ | |
$class = new __CLASS__; | |
$class->select(self::$cached_columns)->find_all(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment