http://symfony.com/doc/current/book/doctrine.html
public function getModulesGroupByBlock($container, $layout_id, $page_id, $module_status = 2) {
try {
$conn = $container->get('doctrine')->getConnection();
$status_str = '';
if($module_status == 1)
{
$status_str = ' and status = 1';
}
$query = 'SELECT block_number,id,page_id,layout_id,zone_id,zone_type,template_module_id,layout_module_id,module_name,module_type,page_level_config,status,sort FROM page_module'
. ' WHERE page_id = ' . $page_id . ' and layout_id = ' . $layout_id . $status_str . ' ORDER BY block_number, zone_id, zone_type, sort;';
$db = $conn->executeQuery($query);
$block_modules = $db->fetchAll(\PDO::FETCH_GROUP);
$block_modules = array_values($block_modules);
return $block_modules;
} catch (\Exception $exc) {
}
return null;
}
public function getListActiveLayout($pageType, $locale)
{
$ret = array();
$deleted = Constant::PAGE_STATUS_DELETED;
// Build Query
$qb = $this->_em->getRepository('inSingDataSourceBundle:PageContent')->createQueryBuilder('pc');
$qb->select('l.id');
$qb->leftJoin('inSingDataSourceBundle:Layout', 'l', 'WITH', 'l.id = pc.layout');
$qb->where('pc.pageType = :pageType');
$qb->andWhere('pc.countryCode = :countryCode');
$qb->andWhere($qb->expr()->isNotNull('pc.layout'));
$qb->andWhere("pc.status NOT IN('$deleted')");
$qb->setParameter('pageType', $pageType);
$qb->setParameter('countryCode', $locale);
$listActiveLayout = $qb->getQuery()->getArrayResult();
if(!empty($listActiveLayout)) {
foreach ($listActiveLayout as $item) {
$ret[] = $item['id'];
}
}
return $ret;
}
public function getListUsingLayout($pageType, $locale) {
$ret = array();
$deleted = Constant::PAGE_STATUS_DELETED;
// Build Query
$qb = $this->createQueryBuilder('l');
$qb->select('l.id,l.isDefault');
$qb->innerJoin('inSingDataSourceBundle:PageModule', 'pm', 'WITH', 'l.id = pm.layout');
$qb->innerJoin('inSingDataSourceBundle:PageContent', 'pc', 'WITH', 'pc.id = pm.pageContent');
$qb->where('l.pageType = :pageType');
$qb->andWhere('l.countryCode = :countryCode');
$qb->andWhere("pc.status NOT IN('$deleted')");
$qb->groupBy('l.id');
$qb->setParameter('pageType', $pageType);
$qb->setParameter('countryCode', $locale);
$listUsingLayout = $qb->getQuery()->getArrayResult();
if(!empty($listUsingLayout)) {
foreach ($listUsingLayout as $item) {
$ret[] = $item['id'];
}
}
return $ret;
}
public function getAssociatingRound($id){
$qb = $this->_model->createQueryBuilder('FightingRound');
$qb->select('FightingRound', 'FightingTable', 'Tournament');
$qb->join('FightingRound.FightingTable', 'FightingTable');
$qb->join('FightingTable.Tournament', 'Tournament');
$qb->where('FightingRound.FightingRoundId = :id');
$qb->setParameter('id', $id);
// $result = $qb->getQuery()->getSql();
// echo $result;
$result = $qb->getQuery()->execute();
// var_dump($result);die;
if($result && count($result) ){
return current($result);
}
return null;
}
public function getAreasForForm(){
$query = self::$_entityManager
->createQuery('SELECT a.AreaId, a.Name FROM Common\Entity\Area a WHERE a.IsVisible=1');
$areas = $query->getResult();
$result = null;
foreach($areas as $area){
$result[$area['AreaId']] = $area['Name'];
}
return $result;
}
public function getAllAreas(){
$query = self::$_entityManager
->createQuery('SELECT a.Code, a.Name FROM Common\Entity\Area a WHERE a.IsVisible=1');
$areas = $query->getResult();
return $areas;
}
public function getTeamsOfTournamentForKOFormBackup($match)
{
$fightingTableId = $match->getFightingTable()->getFightingTableId();
$tournamentId = $match->getFightingTable()
->getTournament()
->getTournamentId();
$teamsOfMatchQuery = '';
if ($match->getHomeTeam()) {
$teamsOfMatchQuery .= " OR Team.TeamId IN ('{$match->getHomeTeam()->getTeamId()}'";
if ($match->getAwayTeam()) {
$teamsOfMatchQuery .= ",'{$match->getAwayTeam()->getTeamId()}'";
}
$teamsOfMatchQuery .= ')';
} else {
if ($match->getAwayTeam()) {
$teamsOfMatchQuery = " OR Team.TeamId = '{$match->getAwayTeam()->getTeamId()}'";
}
}
$sql = "SELECT TeamId, Name FROM Team
WHERE Team.TournamentId='$tournamentId'
AND (
(TeamId NOT IN (select HomeTeamId from FightingMatch WHERE FightingMatch.FightingTableId = '$fightingTableId' AND HomeTeamId IS NOT NULL)
AND TeamId NOT IN (select AwayTeamId from FightingMatch WHERE FightingMatch.FightingTableId = '$fightingTableId' AND AwayTeamId IS NOT NULL))
$teamsOfMatchQuery
)";
$stmt = $this->getEntityManager()
->getConnection()
->prepare($sql);
$stmt->execute();
$teams = $stmt->fetchAll();
$result = array(
'' => '--No Team--'
);
foreach ($teams as $team) {
$result[$team['TeamId']] = $team['Name'];
}
return $result;
}
public function getTournamentQuery($sortby, $ordering, $searchBy, $searchText)
{
$model = self::getEntityManager()->getRepository('Common\Entity\Tournament');
$qb = $model->createQueryBuilder('T');
$qb->select('T', 'City', 'Area');
$qb->leftJoin('T.City', 'City');
$qb->leftJoin('City.Area', 'Area');
if ($searchBy && $searchText) {
if ($searchBy == 'All') {
$qb->where($qb->expr()
->andX($qb->expr()
->orX($qb->expr()
->like('City.Name', ':searchText'), $qb->expr()
->like('Area.Name', ':searchText'), $qb->expr()
->like('T.Name', ':searchText'), $qb->expr()
->like('T.ShortName', ':searchText'), $qb->expr()
->like('T.ContactInfo', ':searchText'), $qb->expr()
->like('T.Description', ':searchText'), $qb->expr()
->like('T.Address', ':searchText'), $qb->expr()
->like('T.Prize', ':searchText'), $qb->expr()
->like('T.Rule', ':searchText')), $qb->expr()
->eq('T.TournamentType', ':FreeTournamentType')));
} else {
$searchBy = str_replace('_', '.', $searchBy);
$qb->where($qb->expr()
->andX($qb->expr()
->like($searchBy, ':searchText'), $qb->expr()
->eq('T.TournamentType', ':FreeTournamentType')));
}
$qb->setParameters(array(
'searchText' => '%' . $searchText . '%'
));
} else {
//
$qb->where('T.TournamentType = :FreeTournamentType');
}
$qb->setParameter('FreeTournamentType', \Common\Entity\Tournament::FREE_TOURNAMENT_TYPE);
// echo $qb->getQuery()->getSql();
// die();
if ($sortby && $ordering) {
// echo $sortby;echo $ordering;die;
$sortby = str_replace('_', '.', $sortby);
$qb->orderBy($sortby, $ordering);
} else {
$qb->orderBy('T.TournamentId', 'DESC');
}
// echo $qb->getQuery()->getSql();
// var_dump($qb->getParameters());
// die();
return $qb;
}
Đăng ký:
Đăng Nhận xét (Atom)
Học lập trình web căn bản với PHP
Bài 1: Các kiến thức căn bản Part 1: https://jimmyvan88.blogspot.com/2012/05/can-ban-lap-trinh-web-voi-php-bai-1-cac.html Part 2: https://...
-
IMindMap 8.0.4 iMindMap là công cụ tuyệt vời để vẽ bản đồ tư duy đem mọi chi tiết trong đầu bạn ra thành các ý tươgnr, để nắm bắt ý tư...
-
1. Download Bamboo in : http://www.atlassian.com/software/bamboo/download?os=linux cd ~ mkdir BAMBOO cd BAMBOO wget http://www.atlassia...
-
1.Giới thiệu về Vim Vim – Vi iMprove là bản cải thiện của Vim – một trình soạn thảo phổ biến trên Unix. Vim có tính cấu hình rất cao ...
Không có nhận xét nào:
Đăng nhận xét