12 const TABLE_NAME =
"Account_App";
14 public $IdAccount = 0;
16 public $DateCreated =
"";
17 public $DateUpdated =
"";
23 public function __construct($src = null, $stripSlashes =
false) {
30 $this->_loadByRow($src, $stripSlashes);
42 public static function Exists($idAccount, $idApp, &$record = NULL) {
45 if ($idAccount > 0 && $idApp > 0) {
46 $sql = sprintf(
"SELECT * FROM %s WHERE IdAccount = %d AND IdApp = %d", self::GetTableName(__CLASS__), $idAccount, $idApp);
47 $res = $Database->Query($sql);
48 $row = $Database->FetchAssoc($res);
50 $record =
new self($row);
64 if ($idAccount > 0 && $idApp > 0) {
66 if (!self::Exists($idAccount, $idApp, $record)) {
68 $record->IdAccount = $idAccount;
69 $record->IdApp = $idApp;
71 return $record->Save();
85 public static function Load ($limit = null, $offset = null, &$count = null, $returnArray =
false) {
86 return self::_load(self::GetTableName(__CLASS__), ($returnArray ?
"" : __CLASS__), NULL,
"DateCreated DESC", $limit, $offset, $count);
96 if (!$this->DateCreated) {
97 $this->DateCreated = Utils::GetCurrentDateTimeFormat();
99 $this->DateUpdated = Utils::GetCurrentDateTimeFormat();
100 $query = sprintf(
"REPLACE INTO %s (IdAccount, IdApp, DateCreated, DateUpdated) VALUES (%d, %d, %s, %s)",
101 self::GetTableName(__CLASS__),
104 $Database->EscapeDate($this->DateCreated),
105 $Database->EscapeDate($this->DateUpdated));
106 return $Database->Query($query);
115 if ($this->IdAccount > 0 && $this->IdApp > 0) {
116 return $this->_Delete(self::GetTableName(__CLASS__), sprintf(
"IdAccount = %d AND IdApp = %d", $this->IdAccount, $this->IdApp));
__construct($src=null, $stripSlashes=false)
static Exists($idAccount, $idApp, &$record=NULL)
static Load($limit=null, $offset=null, &$count=null, $returnArray=false)
static InsertOrUpdate($idAccount, $idApp)