12 const TABLE_NAME =
"AppCustomData";
14 public $IdAccount = 0;
17 public $DataValue =
"";
22 public function __construct($src = null, $stripSlashes =
false) {
23 if (!empty($src) && is_array($src)) {
25 $this->_loadByRow($src, $stripSlashes);
37 public static function Load ($idApp, $idAccount, $returnArray =
false) {
38 $where = sprintf(
"IdApp = %d AND IdAccount = %d", $idApp, $idAccount);
39 return self::_load(self::GetTableName(__CLASS__), ($returnArray ?
"" : __CLASS__), $where);
49 $query = sprintf(
"REPLACE INTO %s (IdAccount, IdApp, DataKey, DataValue) VALUES (%d, %d, '%s', '%s')",
50 self::GetTableName(__CLASS__),
53 $Database->Escape($this->DataKey),
54 $Database->Escape($this->DataValue));
55 return $Database->Query($query);
65 if ($this->IdApp > 0 && $this->IdAccount > 0 && !empty($this->DataKey)) {
66 return $this->_Delete(self::GetTableName(__CLASS__), sprintf(
"IdApp = %d AND IdAccount = %d AND DataKey = '%s'", $this->IdApp, $this->IdAccount, $Database->Escape($this->DataKey)));
74 public static function Prune() {
75 self::TruncateClass(__CLASS__);
86 public static function SetCustomData($idApp, $idAccount, $key, $value) {
88 $data->IdApp = $idApp;
89 $data->IdAccount = $idAccount;
90 $data->DataKey = $key;
91 $data->DataValue = $value;
103 if (!is_array($keys)) {
104 $keys = array($keys);
107 foreach ($keys as $key) {
109 $data->IdApp = $idApp;
110 $data->IdAccount = $idAccount;
111 $data->DataKey = $key;
112 if ($data->Delete()) {
static Load($idApp, $idAccount, $returnArray=false)
static DeleteCustomData($idApp, $idAccount, $keys)
static SetCustomData($idApp, $idAccount, $key, $value)
__construct($src=null, $stripSlashes=false)