/** * @param $userId * @param $browsingId * @return bool */ private function _hasBrowsingToUser($userId, $browsingId) { $query = 'select count(1) from usersinbrowsings where user_id=:user_id and browsing_id=:browsing_id;'; $params = array(); $params['user_id'] = $userId; $params['browsing_id'] = $browsingId; $stmt = parent::prepare($query); $stmt->execute($params); return $stmt->fetchColumn() != 0; }
/** * @param $browsingId * @param $url * @param $date * @return bool */ private function _hasBrowsingView($browsingId, $url, $date) { $query = 'select count(1) from browsingviews where browsing_id=:browsing_id and url=:url and created_date>=:created_date;'; $params = array(); $params['browsing_id'] = $browsingId; $params['url'] = $url; $params['created_date'] = $date->format('Y-m-d'); $stmt = parent::prepare($query); $stmt->execute($params); return $stmt->fetchColumn() != 0; }
/** * @param $name * @return null|RoleEntity */ public function getRoleByName($name) { $roleEntity = null; $sqlProperty = implode(', ', RoleEntity::$SQL_PROPERTY); $query = "select {$sqlProperty} from roles where name=:name_role;"; $params = array(); $params['name_role'] = $name; $stmt = parent::prepare($query); $stmt->execute($params); while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $roleEntity = new RoleEntity($row); } return $roleEntity; }
/** * @param $id */ public function delete($id) { $query = 'delete from commentsonpage where page_id=:id;'; $params = array(); $params['id'] = $id; $stmt = parent::prepare($query); $stmt->execute($params); $query = 'delete from pages where id=:id or parent_id=:id or parent_ids like :id_0 or parent_ids like :0_id_0 or parent_ids like :0_id;'; $params = array(); $params['id'] = $id; $params['id_0'] = "{$id}|%"; $params['0_id_0'] = "%|{$id}|%"; $params['0_id'] = "%|{$id}"; $stmt = parent::prepare($query); $stmt->execute($params); }
/** * @param $id * @param $lockoutEnabled * @param $lockoutEndDate */ public function changeLockout($id, $lockoutEnabled, $lockoutEndDate) { $query = 'update users set lockout_enabled=:lockout_enabled, lockout_end_date=:lockout_end_date where id=:id;'; $params = array(); $params['lockout_enabled'] = $lockoutEnabled ? 1 : 0; $params['lockout_end_date'] = $lockoutEndDate->format('Y-m-d H:i:s'); $params['id'] = $id; $stmt = parent::prepare($query); $stmt->execute($params); }