admin.aprsto/htdocs/includes/repositories/packetognrepository.class.php
Steve White ae9ece5266 *** Initial Commit of Files for APRS.TO Backend Administration Panel ***
This code is non-functional at this point.
2025-02-02 15:53:34 -05:00

67 lines
1.8 KiB
PHP

<?php
class PacketOgnRepository extends ModelRepository
{
private static $_singletonInstance = null;
public function __construct()
{
parent::__construct('PacketOgn');
}
/**
* Returnes an initiated PacketOgnRepository
*
* @return PacketOgnRepository
*/
public static function getInstance()
{
if (self::$_singletonInstance === null) {
self::$_singletonInstance = new PacketOgnRepository();
}
return self::$_singletonInstance;
}
/**
* Get object by id
*
* @param int $id
* @param int $timestamp (optional timestamp which is used by query planner to optimize the query)
* @return PacketOgn
*/
public function getObjectById($id, $timestamp=null)
{
if (!isInt($id) || (!is_null($timestamp) && !isInt($timestamp)))
{
return new PacketOgn(0);
}
if (is_null($timestamp))
return $this->getObjectFromSql('select * from packet_ogn where id = ?', [$id]);
else
return $this->getObjectFromSql('select * from packet_ogn where id = ? and timestamp = ?', [$id, $timestamp]);
}
/**
* Get object by packet id
*
* @param int $id
* @param int $timestamp (optional timestamp which is used by query planner to optimize the query)
* @return PacketOgn
*/
public function getObjectByPacketId($packetId, $timestamp=null)
{
if (!isInt($packetId) || (!is_null($timestamp) && !isInt($timestamp)))
{
return new PacketOgn(0);
}
if (is_null($timestamp))
return $this->getObjectFromSql('select * from packet_ogn where packet_id = ?', [$packetId]);
else
return $this->getObjectFromSql('select * from packet_ogn where packet_id = ? and timestamp = ?', [$packetId, $timestamp]);
}
}