2020-07-04 10:49:43 +00:00
|
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Author: lopiu
|
|
|
|
|
* Date: 04.07.2020
|
|
|
|
|
* Time: 13:17
|
|
|
|
|
*/
|
2020-10-28 20:21:08 +00:00
|
|
|
|
namespace Battles\Models;
|
|
|
|
|
use Exceptions\GameException;
|
2020-07-04 10:49:43 +00:00
|
|
|
|
|
|
|
|
|
class PresentsModel
|
|
|
|
|
{
|
2020-07-05 21:16:22 +00:00
|
|
|
|
protected $DB;
|
|
|
|
|
|
|
|
|
|
public function __construct(int $user_id)
|
|
|
|
|
{
|
2020-07-22 09:27:05 +00:00
|
|
|
|
if (!$this->DB) {
|
2020-10-28 20:21:08 +00:00
|
|
|
|
$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>");
|
2020-07-22 09:27:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-05 21:16:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getAllPresents()
|
|
|
|
|
{
|
|
|
|
|
return $this->DB;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getPresentsSum()
|
|
|
|
|
{
|
|
|
|
|
return $this->DB->getNumRows();
|
2020-07-04 10:49:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|