Combu Server  3.1.1
PHP API Documentation
UserGroupAccount.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Combu;
4 
10 class UserGroupAccount extends DataClass {
11 
12  const TABLE_NAME = "UserGroupAccount";
13 
14  public $IdGroup = 0;
15  public $IdAccount = 0;
16 
20  public function __construct($src = null, $stripSlashes = false) {
21  global $Database;
22  if ($src == null)
23  return;
24  if (is_array($src)) {
25  // Load by array
26  $this->_loadByRow($src, $stripSlashes);
27  }
28  }
29 
36  public static function Exists($idGroup, $idAccount) {
37  global $Database;
38  $where = sprintf("IdGroup = %d AND IdAccount = %d", $idGroup, $idAccount);
39  $recs = self::_load(self::GetTableName(__CLASS__), "", $where);
40  return (count($recs) > 0);
41  }
42 
49  public static function Load ($idGroup = 0, $idAccount = 0, $returnArray = false) {
50  $where = NULL;
51  if ($idGroup > 0)
52  $where .= ($where ? " AND " : "") . sprintf("(IdGroup = %d)", $idGroup);
53  if ($idAccount > 0)
54  $where .= ($where ? " AND " : "") . sprintf("(IdAccount = %d)", $idAccount);
55  return self::_load(self::GetTableName(__CLASS__), ($returnArray ? "" : __CLASS__), $where);
56  }
57 
63  public function Save() {
64  global $Database;
65  if ($this->IdGroup <= 0 || $this->IdAccount <= 0)
66  return FALSE;
67  $query = sprintf("REPLACE INTO %s (IdGroup, IdAccount) VALUES (%d, %d)",
68  self::GetTableName(__CLASS__),
69  $this->IdGroup,
70  $this->IdAccount);
71  return $Database->Query($query);
72  }
73 
79  public function Delete() {
80  if ($this->IdGroup > 0 && $this->IdAccount > 0) {
81  return $this->_Delete(self::GetTableName(__CLASS__), sprintf("IdGroup = %d AND IdAccount = %d", $this->IdGroup, $this->IdAccount));
82  }
83  return FALSE;
84  }
85 }
static Exists($idGroup, $idAccount)
static Load($idGroup=0, $idAccount=0, $returnArray=false)
Definition: Account.php:3
__construct($src=null, $stripSlashes=false)