public static function count(array $options = []) { $db = new Util\Data(); $db->buildQuery('select', 'count(gadget.id)'); $db->buildQuery('from', 'cms_gadget `gadget`'); $db->extendQuery($options); return $db->count(); }
public static function count(array $options = []) { $db = new Util\Data(); $db->buildQuery('select', 'count(log.id)'); $db->buildQuery('from', 'core_log `log`'); $db->extendQuery($options); return $db->count(); }
public static function count(array $options = []) { $db = new Util\Data(); $db->buildQuery('select', 'count(*)'); $db->buildQuery('from', 'core_role_permission `role_permission`'); $db->extendQuery($options); return $db->count(); }
public static function count(array $options = []) { $db = new Util\Data(); $db->buildQuery('select', 'count(user_security.id)'); $db->buildQuery('from', 'core_user_security `user_security`'); $db->extendQuery($options); return $db->count(); }
public static function count(array $options = []) { $db = new Util\Data(); $db->buildQuery('select', 'count(module_media.id)'); $db->buildQuery('from', 'cms_module_media `module_media`'); $db->extendQuery($options); return $db->count(); }
public static function hasMembership($courtId, array $playerIds) { $today = new \DateTime(); $today = $today->format('Y-m-d'); $db = new Util\Data(); $db->buildQuery('select', 'count(m.id)'); $db->buildQuery('from', 'bus_membership m'); $db->buildQuery('join', 'bus_membership_court mc ON mc.membership_id = m.id'); $db->buildQuery('join', 'bus_player_membership pm ON pm.membership_id = m.id'); $db->buildQuery('where', ['m.start_date <= ? AND m.end_date >= ?', $today, $today]); $db->buildQuery('where', ['mc.court_id = ?', $courtId]); $db->buildQuery('where', ['pm.player_id IN (?)', $playerIds]); return $db->count(); }
public static function loadByParent($pageId, $depth) { $db = new Util\Data(); for ($i = 1; $i <= $depth; $i++) { $db->buildQuery('select', self::getList(['id'])); $db->buildQuery('from', 'cms_page page'); $db->buildQuery('where', ['id = ?', $pageId]); $db->buildQuery('limit', 1); $pageId = $db->count($query, $db); if ($pageId == 1) { return $pageId; } unset($query); } return $pageId; }
public function validateTitle() { $v = Util\Validate::validate('title', $this->getModel()->getTitle(), $this->titleValidator); if ($v->getResult() == ResultType::ERROR) { return $v; } $db = new Util\Data(); $options = []; $options['where'][] = ['folder.title = ?', $this->getModel()->getTitle()]; $options['where'][] = ['folder.folderId != ?', $this->getModel()->getId()]; $exist = $db->count($options); if ($exist >= 1) { $v->setResult(ResultType::ERROR); $v->setMessage('a folder already exists with this name'); } return $v; }
public static function hasAccess($userId, $permission, $isAdmin) { $db = new Util\Data(); $db->buildQuery('select', 'count(user.id)'); $db->buildQuery('from', 'core_user user'); $db->buildQuery('join', 'core_user_role user_role ON user_role.user_id = user.id'); $db->buildQuery('join', 'core_role role ON role.id = user_role.role_id'); $db->buildQuery('join', 'core_role_permission role_permission ON role_permission.role_id = user_role.role_id'); $db->buildQuery('join', 'core_permission permission ON permission.id = role_permission.permission_id'); $db->buildQuery('where', 'user.id = ' . $userId); if ($isAdmin) { $db->buildQuery('where', 'user.is_admin = 1'); } $db->buildQuery('where', ['? LIKE CONCAT(permission.title, "%") OR permission.title LIKE CONCAT(?, "%")', $permission, $permission]); $db->buildQuery('where', 'user.status = 1'); $db->buildQuery('where', 'role.status = 1'); $db->buildQuery('where', 'permission.status = 1'); return $db->count(); }
public static function emailExists($email, $id) { $db = new Util\Data(); $db->buildQuery('select', 'count(user.id)'); $db->buildQuery('from', 'core_user `user`'); $db->buildQuery('where', ['user.email = ?', $email]); $db->buildQuery('where', ['user.id != ?', $id]); return $db->count(); }
public static function getNextContentGroup($moduleId) { $query = 'SELECT MAX(content_group) FROM cms_content WHERE module_id = ?'; $db = new Util\Data(); return $db->count($query, [$moduleId]) + 1; }