battles/classes/Battles/Models/PresentsModel.php

33 lines
738 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Author: lopiu
* Date: 04.07.2020
* Time: 13:17
*/
namespace Battles\Models;
use Exceptions\GameException;
class PresentsModel
{
protected $DB;
public function __construct(int $user_id)
{
if (!$this->DB) {
$this->DB = \db::c()->query('SELECT sender_id, image FROM `users_presents` WHERE owner_id = ?i', $user_id);
if ($this->DB->getNumRows() == 0) {
throw new GameException("<div class='debug'>class PresentsModel: Не прогрузилась база!</div>");
}
}
}
public function getAllPresents()
{
return $this->DB;
}
public function getPresentsSum()
{
return $this->DB->getNumRows();
}
}