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
2011-05-28 19:46:46 +10:00

74 lines
2.0 KiB
PHP

<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class extends Kohana's [ORM] class to create defaults for TSM.
*
* @package PTA
* @subpackage Core
* @category ORM
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://dev.osbill.net/license.html
*/
class ORMTSM extends ORM {
// Suppress ORMs inclusion of <table_name>.*
protected $_disable_wild_select = TRUE;
// Suppress ORMs inclusion of <table_name>. to column joins
protected $_disable_join_table_name = TRUE;
// Suppress ORMs use of limit
protected $_disable_limit = TRUE;
// To enable effective caching, this must disabled.
protected $_reload_on_wakeup = FALSE;
// Enable the formating of columns
protected $_object_formated = array();
protected $_formated = FALSE;
protected $_formats = array();
public function __construct($id = NULL) {
parent::__construct($id);
// We'll cache our query results
if ($c = $this->_db->caching($this->_table_name))
$this->cached($c);
}
/**
* 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;
}
// Load our values into the ORM object
public function load_object(array $values) {
return parent::_load_values($values);
}
public static function date($date,$format) {
return $date ? date($format,strtotime($date)) : '';
}
}
?>