_init(self::TABLE_NAME, ActiveSessionModel::ID); } public function updateIfSessionInvalid(int $userId, int $adminSessionInfoId): void { if (!$this->isSessionValid($userId, $adminSessionInfoId)) { $connection = $this->getConnection(); $connection->update( $this->getMainTable(), [ActiveSessionModel::ADMIN_SESSION_INFO_ID => $adminSessionInfoId], $connection->quoteInto(ActiveSessionModel::USER_ID . ' = ?', $userId) ); } } public function getAllSessionIds(): array { $connection = $this->getConnection(); $tableName = $this->getMainTable(); $select = $connection->select() ->from( $tableName, [ActiveSessionModel::SESSION_ID] ); return $connection->fetchCol($select); } private function isSessionValid(int $userId, int $adminSessionInfoId): bool { $connection = $this->getConnection(); $select = $connection->select()->from( $this->getMainTable(), [ActiveSessionModel::ADMIN_SESSION_INFO_ID] )->where( ActiveSessionModel::USER_ID . ' = ?', $userId )->limit(1); $result = (int)$connection->fetchOne($select); return $adminSessionInfoId == $result; } }