19 declare(strict_types=1);
33 protected array
$mids = array();
44 protected function __construct(
int $server_id,
int $community_id)
48 $this->db = $DIC->database();
64 return self::$instance[$a_server_id][$a_community_id] ??
85 $this->own_id = $a_id;
95 $this->cname = $a_name;
105 $this->mids = $a_mids;
118 if (!$this->entryExists) {
122 $query =
'UPDATE ecs_community ' .
123 'SET own_id = ' . $this->db->quote($this->
getOwnId(),
'integer') .
', ' .
125 'mids = ' . $this->db->quote(serialize($this->
getMids()),
'text') .
' ' .
126 'WHERE sid = ' . $this->db->quote($this->
getServerId(),
'integer') .
' ' .
127 'AND cid = ' . $this->db->quote($this->
getCommunityId(),
'integer');
128 $this->db->manipulate($query);
139 $query =
'INSERT INTO ecs_community (sid,cid,own_id,cname,mids) ' .
141 $this->db->quote($this->
getServerId(),
'integer') .
', ' .
143 $this->db->quote($this->
getOwnId(),
'integer') .
', ' .
145 $this->db->quote(serialize($this->
getMids()),
'text') .
' ' .
147 $this->db->manipulate($query);
156 $this->entryExists =
false;
158 $query =
'SELECT * FROM ecs_community ' .
159 'WHERE sid = ' . $this->db->quote($this->
getServerId(),
'integer') .
' ' .
160 'AND cid = ' . $this->db->quote($this->
getCommunityId(),
'integer');
161 $res = $this->db->query($query);
163 $this->entryExists =
true;
164 $this->
setOwnId((
int) $row->own_id);
166 $this->
setMids(unserialize($row->mids, [
'allowed_classes' =>
true]));
178 $query =
'DELETE FROM ecs_community' .
179 ' WHERE sid = ' . $this->db->quote($a_server_id,
'integer');
180 $this->db->manipulate($query);