Combu Server  3.1.1
PHP API Documentation
Account_App.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Combu;
4 
10 class Account_App extends DataClass {
11 
12  const TABLE_NAME = "Account_App";
13 
14  public $IdAccount = 0;
15  public $IdApp = 0;
16  public $DateCreated = "";
17  public $DateUpdated = "";
18 
23  public function __construct($src = null, $stripSlashes = false) {
24  global $Database;
25  if (empty($src)) {
26  return;
27  }
28  if (is_array($src)) {
29  // Load by array
30  $this->_loadByRow($src, $stripSlashes);
31  }
32  }
33 
42  public static function Exists($idAccount, $idApp, &$record = NULL) {
43  global $Database;
44  $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);
49  if ($row) {
50  $record = new self($row);
51  return TRUE;
52  }
53  }
54  return FALSE;
55  }
56 
62  public static function InsertOrUpdate($idAccount, $idApp) {
63  global $Database;
64  if ($idAccount > 0 && $idApp > 0) {
65  $record = NULL;
66  if (!self::Exists($idAccount, $idApp, $record)) {
67  $record = new self();
68  $record->IdAccount = $idAccount;
69  $record->IdApp = $idApp;
70  }
71  return $record->Save();
72  }
73  return FALSE;
74  }
75 
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);
87  }
88 
94  public function Save() {
95  global $Database;
96  if (!$this->DateCreated) {
97  $this->DateCreated = Utils::GetCurrentDateTimeFormat();
98  }
99  $this->DateUpdated = Utils::GetCurrentDateTimeFormat();
100  $query = sprintf("REPLACE INTO %s (IdAccount, IdApp, DateCreated, DateUpdated) VALUES (%d, %d, %s, %s)",
101  self::GetTableName(__CLASS__),
102  $this->IdAccount,
103  $this->IdApp,
104  $Database->EscapeDate($this->DateCreated),
105  $Database->EscapeDate($this->DateUpdated));
106  return $Database->Query($query);
107  }
108 
114  public function Delete() {
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));
117  }
118  return FALSE;
119  }
120 }
__construct($src=null, $stripSlashes=false)
Definition: Account_App.php:23
static Exists($idAccount, $idApp, &$record=NULL)
Definition: Account_App.php:42
static Load($limit=null, $offset=null, &$count=null, $returnArray=false)
Definition: Account_App.php:85
Definition: Account.php:3
static InsertOrUpdate($idAccount, $idApp)
Definition: Account_App.php:62