Combu Server  3.1.1
PHP API Documentation
GameMatch_Round.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Combu;
4 
10 class GameMatch_Round extends DataClass {
11 
12  const TABLE_NAME = "Match_Round";
13 
14  public $Id = 0;
15  public $IdMatchAccount = 0;
16  public $Score = 0;
17  public $DateScore = NULL;
18 
22  public function __construct($src = null, $stripSlashes = false) {
23  global $Database;
24  if ($src == null)
25  return;
26  if (is_array($src)) {
27  // Load by array
28  $this->_loadByRow($src, $stripSlashes);
29  } else if (is_numeric($src) && intval($src) > 0) {
30  // Load by Id
31  $this->_loadFilter(self::GetTableName(__CLASS__), "Id = " . intval($src));
32  }
33  }
34 
41  public static function Load($idMatchAccount = 0) {
42  global $Database;
43  $where = "";
44  if ($idMatchAccount > 0) {
45  $where .= ($where == "" ? "" : " AND ") . sprintf("(IdMatchAccount = %d)", $idMatchAccount);
46  }
47  return self::_load(self::GetTableName(__CLASS__), __CLASS__, $where);
48  }
49 
55  public function Save() {
56  global $Database;
57  if ($this->Id > 0) {
58  $query = sprintf("UPDATE %s SET Score = %f, DateScore = %s WHERE Id = %d",
59  self::GetTableName(__CLASS__),
60  $this->Score,
61  $Database->EscapeDate($this->DateScore),
62  $this->Id);
63  } else {
64  $this->DateCreation = date("Y-m-d H:i:s");
65  $query = sprintf("INSERT INTO %s (IdMatchAccount, Score, DateScore) VALUES (%d, %f, %s)",
66  self::GetTableName(__CLASS__),
67  $this->IdMatchAccount,
68  $this->Score,
69  $Database->EscapeDate($this->DateScore));
70  }
71  if ($Database->Query($query)) {
72  if ($this->Id < 1) {
73  $this->Id = $Database->InsertedId();
74  }
75  return TRUE;
76  }
77  return FALSE;
78  }
79 
84  public function Delete() {
85  if ($this->Id > 0) {
86  if ($this->_Delete(self::GetTableName(__CLASS__), "Id = " . $this->Id)) {
87  $this->_Delete(self::GetTableName(GameMatch_CustomData::class), "IdMatch = " . $this->Id);
88  $this->_Delete(self::GetTableName(GameMatch_Account::class), "IdMatch = " . $this->Id);
89  return TRUE;
90  }
91  }
92  return FALSE;
93  }
94 }
__construct($src=null, $stripSlashes=false)
Definition: Account.php:3
static Load($idMatchAccount=0)