Skip to content

Instantly share code, notes, and snippets.

@shadowhand
Created March 4, 2009 13:28
Show Gist options
  • Save shadowhand/73837 to your computer and use it in GitHub Desktop.
Save shadowhand/73837 to your computer and use it in GitHub Desktop.
<?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