12 const TABLE_NAME =
"Match_Account";
16 public $IdAccount = 0;
17 public $CustomData =
"";
22 public function __construct($src = null, $stripSlashes =
false) {
28 $this->_loadByRow($src, $stripSlashes);
29 }
else if (is_numeric($src) && intval($src) > 0) {
31 $this->_loadFilter(self::GetTableName(__CLASS__),
"Id = " . intval($src));
42 public static function Load($idMatch = 0, $idAccount = 0, $returnArray = FALSE) {
45 $where .= ($where ?
" AND " :
"") . sprintf(
"(IdMatch = %d)", $idMatch);
47 $where .= ($where ?
" AND " :
"") . sprintf(
"(IdAccount = %d)", $idAccount);
48 return self::_load(self::GetTableName(__CLASS__), ($returnArray ?
"" : __CLASS__), $where,
"Id");
58 if ($this->IdMatch < 1 || $this->IdAccount < 1) {
62 $query = sprintf(
"UPDATE %s SET CustomData = '%s' WHERE Id = %d",
63 self::GetTableName(__CLASS__),
64 $Database->Escape($this->CustomData),
67 $this->DateCreation = date(
"Y-m-d H:i:s");
68 $query = sprintf(
"INSERT INTO %s (IdMatch, IdAccount, CustomData) VALUES (%d, %d, '%s')",
69 self::GetTableName(__CLASS__),
72 $Database->Escape($this->CustomData));
74 if ($Database->Query($query)) {
76 $this->Id = $Database->InsertedId();
89 if ($this->_Delete(self::GetTableName(__CLASS__), sprintf(
"Id = %d", $this->Id))) {
90 $this->_Delete(self::GetTableName(GameMatch_Round::class), sprintf(
"IdMatchAccount = %d", $this->Id));
98 $user =
new Account($this->IdAccount);
99 $array = Utils::ObjectToArray($this);
100 $array[
"User"] = $user->ToArray();
101 $array[
"Rounds"] = array();
102 $rounds = GameMatch_Round::Load($this->Id);
103 foreach ($rounds as $r) {
104 $array[
"Rounds"][] = $r->ToArray();
110 $array = $this->ToArray();
111 return json_encode($array);
__construct($src=null, $stripSlashes=false)
static Load($idMatch=0, $idAccount=0, $returnArray=FALSE)