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/orm.php

44 lines
1.2 KiB
PHP
Raw Normal View History

2011-03-03 23:06:18 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class overrides the Kohana ORM for some TSM specific calls.
*
* @package PTA
* @subpackage ORM
* @category Overrides
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class ORM extends Kohana_ORM {
/**
* Override Kohana's FIND to remove the LIMIT
*/
public function find($id = NULL) {
// Since TSM doesnt support LIMIT, we'll use find_all() but return the first record
foreach ($this->find_all() as $object) {
2011-04-05 23:12:31 +00:00
// In TSM Primary Keys are in upper case
if (is_null($id) OR $object->{$object->_primary_key} == strtoupper($id))
$this->_load_values($object->_object);
2011-03-03 23:06:18 +00:00
2011-04-05 23:12:31 +00:00
// If we have found our item return
if ($this->_loaded)
2011-04-07 05:03:05 +00:00
return $object;
2011-03-03 23:06:18 +00:00
}
}
/**
* We need to call our own _load_values() to support find() and TSM::result()
*
* (Since _load_values is protected, we need to make it public here,
* so that it can be called in TSM::result().)
*
* @see TSM::result
* @see ORM::find
*/
public function _load_values(array $values) {
return parent::_load_values($values);
}
}
?>