12 const TABLE_NAME =
"Achievement_User";
15 public $IdAchievement = 0;
16 public $IdAccount = 0;
18 public $LastUpdated =
"";
23 public function __construct($src = null, $stripSlashes =
false) {
29 $this->_loadByRow($src, $stripSlashes);
30 }
else if (is_numeric($src) && intval($src) > 0) {
32 $this->_loadFilter(self::GetTableName(__CLASS__),
"Id = " . intval($src));
44 public static function LoadAccount ($idAccount, $idAchievement = 0, $returnArray =
false) {
45 $where = sprintf(
"IdAccount = %d", $idAccount);
46 if ($idAchievement > 0) {
47 $where .= sprintf(
" AND IdAchievement = %d", $idAchievement);
49 return self::_load(self::GetTableName(__CLASS__), ($returnArray ?
"" : __CLASS__), $where,
"IdAchievement");
62 public static function Load ($idAchievement, $limit = null, $offset = null, &$count = null, $returnArray =
false) {
63 $where = sprintf(
"au.IdAchievement = %d", $idAchievement);
64 return self::_loadEx(
"au.*", self::GetTableName(__CLASS__) .
" au INNER JOIN " . self::GetTableName(Account::class) .
" u ON u.Id = au.IdAccount", ($returnArray ?
"" : __CLASS__), $where,
"u.Username", $limit, $offset, $count);
74 $this->LastUpdated = date(
"Y-m-d H:i:s");
76 $query = sprintf(
"INSERT INTO %s (IdAchievement, IdAccount, Progress, LastUpdated) VALUES (%d, %d, %d, %s)",
77 self::GetTableName(__CLASS__),
81 $Database->EscapeDate($this->LastUpdated));
83 $query = sprintf(
"UPDATE %s SET Progress = %d, LastUpdated = %s WHERE Id = %d",
84 self::GetTableName(__CLASS__),
86 $Database->EscapeDate($this->LastUpdated),
89 $saved = $Database->Query($query);
92 $this->Id = $Database->InsertedId();
108 return $this->_Delete(self::GetTableName(__CLASS__),
"Id = " . $this->Id);
115 self::TruncateClass(__CLASS__);
__construct($src=null, $stripSlashes=false)
static Load($idAchievement, $limit=null, $offset=null, &$count=null, $returnArray=false)
static LoadAccount($idAccount, $idAchievement=0, $returnArray=false)