47 lines
970 B
PHP
47 lines
970 B
PHP
<?php
|
|
|
|
class ReceiverRepository extends ModelRepository
|
|
{
|
|
|
|
private static $_singletonInstance = null;
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct('Receiver');
|
|
}
|
|
|
|
/**
|
|
* Returnes an initiated ReceiverRepository
|
|
*
|
|
* @return ReceiverRepository
|
|
*/
|
|
public static function getInstance()
|
|
{
|
|
if (self::$_singletonInstance === null) {
|
|
self::$_singletonInstance = new ReceiverRepository();
|
|
}
|
|
|
|
return self::$_singletonInstance;
|
|
}
|
|
|
|
/**
|
|
* Get object by id
|
|
*
|
|
* @param int $id
|
|
* @return Receiver
|
|
*/
|
|
public function getObjectById($id)
|
|
{
|
|
if (!isInt($id)) {
|
|
return new Receiver(0);
|
|
}
|
|
|
|
static $cache = array();
|
|
$key = $id;
|
|
if (!isset($cache[$key])) {
|
|
$cache[$key] = $this->getObjectFromSql('select * from receiver where id = ?', [$id]);
|
|
}
|
|
return $cache[$key];
|
|
}
|
|
}
|