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.
phptsmadmin/application/classes/ormtsm.php

74 lines
2.0 KiB
PHP
Raw Normal View History

2011-04-05 23:12:31 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class extends Kohana's [ORM] class to create defaults for TSM.
*
2011-05-23 10:01:27 +00:00
* @package PTA
2011-04-05 23:12:31 +00:00
* @subpackage Core
* @category ORM
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://dev.osbill.net/license.html
*/
2011-05-23 10:01:27 +00:00
class ORMTSM extends ORM {
2011-04-05 23:12:31 +00:00
// Suppress ORMs inclusion of <table_name>.*
protected $_disable_wild_select = TRUE;
2011-04-07 05:03:05 +00:00
// Suppress ORMs inclusion of <table_name>. to column joins
protected $_disable_join_table_name = TRUE;
2011-04-08 05:34:04 +00:00
// Suppress ORMs use of limit
protected $_disable_limit = TRUE;
2011-05-28 09:46:46 +00:00
// To enable effective caching, this must disabled.
protected $_reload_on_wakeup = FALSE;
2011-04-05 23:12:31 +00:00
// Enable the formating of columns
2011-05-28 09:46:46 +00:00
protected $_object_formated = array();
2011-04-05 23:12:31 +00:00
protected $_formated = FALSE;
protected $_formats = array();
2011-05-31 00:42:47 +00:00
protected function _load_result($multiple = FALSE) {
2011-05-28 09:46:46 +00:00
// We'll cache our query results
if ($c = $this->_db->caching($this->_table_name))
2011-05-31 00:42:47 +00:00
$this->_db_builder->cached($c);
return parent::_load_result($multiple);
2011-05-28 09:46:46 +00:00
}
/**
* Proxy method to Database list_columns.
* This enables caching of the list_columns queries. Since this doesnt
* we hard code the cache to 7 days.
*
* @return array
*/
public function list_columns() {
// We'll cache our query results
if ($this->_db->caching('SCHEMA')) {
// Set the cache key based on the database instance name and SQL
$cache_key = 'Database::query(LC:'.$this->_table_name.')';
if ($result = Cache::instance()->get($cache_key))
// Return a cached result
return $result;
}
// Proxy to database
$result = $this->_db->list_columns($this->_table_name);
// Cache the result array
if (isset($cache_key))
Cache::instance()->set($cache_key, $result, 604800);
return $result;
}
2011-05-23 10:01:27 +00:00
// Load our values into the ORM object
public function load_object(array $values) {
return parent::_load_values($values);
2011-04-05 23:12:31 +00:00
}
public static function date($date,$format) {
return $date ? date($format,strtotime($date)) : '';
2011-04-05 23:12:31 +00:00
}
}
?>