/** Creates the query by building on a queryBuilder object as * required by the supplied parameters */ public function createQuery() { $parameters = $this->validParams; $binds = array(); $bc = -1; $qb = $this->em->createQueryBuilder(); //Initialize base query $qb->select('sg', 'r', 'u', 'rt')->from('ServiceGroup', 'sg')->leftJoin('sg.roles', 'r')->leftJoin('r.user', 'u')->leftJoin('r.roleType', 'rt')->orderBy('sg.id', 'ASC'); /*Pass parameters to the ParameterBuilder and allow it to add relevant where clauses * based on set parameters. */ $parameterBuilder = new ParameterBuilder($parameters, $qb, $this->em, $bc); //Get the result of the scope builder $qb = $parameterBuilder->getQB(); $bc = $parameterBuilder->getBindCount(); //Get the binds and store them in the local bind array - only runs if the returned value is an array foreach ((array) $parameterBuilder->getBinds() as $bind) { $binds[] = $bind; } //Run ScopeQueryBuilder regardless of if scope is set. $scopeQueryBuilder = new ScopeQueryBuilder(isset($parameters['scope']) ? $parameters['scope'] : null, isset($parameters['scope_match']) ? $parameters['scope_match'] : null, $qb, $this->em, $bc, 'ServiceGroup', 'sg'); //Get the result of the scope builder $qb = $scopeQueryBuilder->getQB(); $bc = $scopeQueryBuilder->getBindCount(); //Get the binds and store them in the local bind array only if any binds are fetched from scopeQueryBuilder foreach ((array) $scopeQueryBuilder->getBinds() as $bind) { $binds[] = $bind; } //Bind all variables $qb = $this->helpers->bindValuesToQuery($binds, $qb); //Get the dql query from the Query Builder object $query = $qb->getQuery(); $this->query = $query; return $this->query; }
/** Creates the query by building on a queryBuilder object as * required by the supplied parameters */ public function createQuery() { $parameters = $this->validParams; $binds = array(); $bc = -1; $qb = $this->em->createQueryBuilder(); //Initialize base query $qb->select('se', 'sp', 's', 'sc', 'el', 'c', 'n', 'st', 'elp')->from('Service', 'se')->leftjoin('se.parentSite', 's')->leftjoin('s.certificationStatus', 'cs')->leftJoin('s.scopes', 'sc')->leftJoin('se.serviceProperties', 'sp')->leftjoin('se.endpointLocations', 'el')->leftjoin('el.endpointProperties', 'elp')->leftjoin('s.country', 'c')->leftjoin('s.ngi', 'n')->leftjoin('se.serviceType', 'st')->andWhere($qb->expr()->neq('cs.name', '?' . ++$bc))->orderBy('se.id', 'ASC'); //Add closed parameter to binds $binds[] = array($bc, 'Closed'); /*Pass parameters to the ParameterBuilder and allow it to add relevant where clauses * based on set parameters. */ $parameterBuilder = new ParameterBuilder($parameters, $qb, $this->em, $bc); //Get the result of the scope builder $qb = $parameterBuilder->getQB(); $bc = $parameterBuilder->getBindCount(); //Get the binds and store them in the local bind array - only runs if the returned value is an array foreach ((array) $parameterBuilder->getBinds() as $bind) { $binds[] = $bind; } //Run ScopeQueryBuilder regardless of if scope is set. $scopeQueryBuilder = new ScopeQueryBuilder(isset($parameters['scope']) ? $parameters['scope'] : null, isset($parameters['scope_match']) ? $parameters['scope_match'] : null, $qb, $this->em, $bc, 'Service', 'se'); //Get the result of the scope builder $qb = $scopeQueryBuilder->getQB(); $bc = $scopeQueryBuilder->getBindCount(); //Get the binds and store them in the local bind array only if any binds are fetched from scopeQueryBuilder foreach ((array) $scopeQueryBuilder->getBinds() as $bind) { $binds[] = $bind; } /* Pass the properties to the properties class. * It will return a query with a clause based on the provided LDAP */ if (isset($parameters['extensions'])) { $ExtensionsQueryBuilder = new ExtensionsQueryBuilder($parameters['extensions'], $qb, $this->em, $bc, 'Service'); //Get the modified query $qb = $ExtensionsQueryBuilder->getQB(); $bc = $ExtensionsQueryBuilder->getBindCount(); //Get the binds and store them in the local bind array foreach ($ExtensionsQueryBuilder->getValuesToBind() as $value) { $binds[] = $value; } } //Bind all variables $qb = $this->helpers->bindValuesToQuery($binds, $qb); /* $dql = $qb->getDql(); //for testing $query = $qb->getQuery(); echo "\n\n\n\n"; $parameters=$query->getParameters(); print_r($parameters); echo $dql; echo "\n\n\n\n"; */ //Get the dql query from the Query Builder object $query = $qb->getQuery(); $this->query = $query; return $this->query; }
/** Creates the query by building on a queryBuilder object as * required by the supplied parameters */ public function createQuery() { $parameters = $this->validParams; $binds = array(); $bc = -1; $qb = $this->em->createQueryBuilder(); $qb->select('s', 'sc', 'sp', 'i', 'cs', 'c', 'n', 'sgrid', 'ti')->from('Site', 's')->leftJoin('s.siteProperties', 'sp')->leftJoin('s.scopes', 'sc')->leftJoin('s.ngi', 'n')->leftJoin('s.country', 'c')->leftJoin('s.certificationStatus', 'cs')->leftJoin('s.infrastructure', 'i')->leftJoin('s.subGrid', 'sgrid')->leftJoin('s.tier', 'ti')->orderBy('s.shortName', 'ASC'); /*Pass parameters to the ParameterBuilder and allow it to add relevant where clauses * based on set parameters. */ $parameterBuilder = new ParameterBuilder($parameters, $qb, $this->em, $bc); //Get the result of the scope builder $qb = $parameterBuilder->getQB(); $bc = $parameterBuilder->getBindCount(); //Get the binds and store them in the local bind array - only runs if the returned value is an array foreach ((array) $parameterBuilder->getBinds() as $bind) { $binds[] = $bind; } //Run ScopeQueryBuilder regardless of if scope is set. $scopeQueryBuilder = new ScopeQueryBuilder(isset($parameters['scope']) ? $parameters['scope'] : null, isset($parameters['scope_match']) ? $parameters['scope_match'] : null, $qb, $this->em, $bc, 'Site', 's'); //Get the result of the scope builder $qb = $scopeQueryBuilder->getQB(); $bc = $scopeQueryBuilder->getBindCount(); //Get the binds and store them in the local bind array only if any binds are fetched from scopeQueryBuilder foreach ((array) $scopeQueryBuilder->getBinds() as $bind) { $binds[] = $bind; } /* Pass the properties to the extensions class. * It will return a query with a clause based on the provided LDAP style query */ if (isset($parameters['extensions'])) { $ExtensionsQueryBuilder = new ExtensionsQueryBuilder($parameters['extensions'], $qb, $this->em, $bc, 'Site'); //Get the modified query $qb = $ExtensionsQueryBuilder->getQB(); $bc = $ExtensionsQueryBuilder->getBindCount(); //Get the binds and store them in the local bind array foreach ($ExtensionsQueryBuilder->getValuesToBind() as $value) { $binds[] = $value; } } //Bind all variables $qb = $this->helpers->bindValuesToQuery($binds, $qb); //Get the dql query from the Query Builder object //Testing /* $dql = $qb->getDql(); //for testing $query = $qb->getQuery(); echo "\n\n\n\n"; $parameters=$query->getParameters(); print_r($parameters); echo $dql; echo "\n\n\n\n"; */ $query = $qb->getQuery(); $this->query = $query; return $this->query; }
/** Creates the query by building on a queryBuilder object as * required by the supplied parameters */ public function createQuery() { $parameters = $this->validParams; $binds = array(); $bc = -1; $qb = $this->em->createQueryBuilder(); //Initialize base query $qb->select('sg', 's', 'st', 'sp', 'sc', 'els', 'elp', 'servp')->from('ServiceGroup', 'sg')->leftJoin('sg.serviceGroupProperties', 'sp')->leftJoin('sg.services', 's')->leftJoin('s.serviceProperties', 'servp')->leftJoin('s.serviceType', 'st')->leftJoin('s.scopes', 'sc')->leftJoin('s.endpointLocations', 'els')->leftjoin('els.endpointProperties', 'elp')->orderBy('sg.id', 'ASC'); /*Pass parameters to the ParameterBuilder and allow it to add relevant where clauses * based on set parameters. */ $parameterBuilder = new ParameterBuilder($parameters, $qb, $this->em, $bc); //Get the result of the scope builder $qb = $parameterBuilder->getQB(); $bc = $parameterBuilder->getBindCount(); //Get the binds and store them in the local bind array - only runs if the returned value is an array foreach ((array) $parameterBuilder->getBinds() as $bind) { $binds[] = $bind; } //Run ScopeQueryBuilder regardless of if scope is set. $scopeQueryBuilder = new ScopeQueryBuilder(isset($parameters['scope']) ? $parameters['scope'] : null, isset($parameters['scope_match']) ? $parameters['scope_match'] : null, $qb, $this->em, $bc, 'ServiceGroup', 'sg'); //Get the result of the scope builder $qb = $scopeQueryBuilder->getQB(); $bc = $scopeQueryBuilder->getBindCount(); //Get the binds and store them in the local bind array only if any binds are fetched from scopeQueryBuilder foreach ((array) $scopeQueryBuilder->getBinds() as $bind) { $binds[] = $bind; } /* Pass the properties to the extensions class. * It will return a query with a clause based on the provided LDAP style query */ if (isset($parameters['extensions'])) { $ExtensionsQueryBuilder = new ExtensionsQueryBuilder($parameters['extensions'], $qb, $this->em, $bc, 'ServiceGroup'); //Get the modified query $qb = $ExtensionsQueryBuilder->getQB(); $bc = $ExtensionsQueryBuilder->getBindCount(); //Get the binds and store them in the local bind array foreach ($ExtensionsQueryBuilder->getValuesToBind() as $value) { $binds[] = $value; } } //Bind all variables $qb = $this->helpers->bindValuesToQuery($binds, $qb); //Get the dql query from the Query Builder object $query = $qb->getQuery(); $this->query = $query; return $this->query; }
/** Creates the query by building on a queryBuilder object as * required by the supplied parameters */ public function createQuery() { $parameters = $this->validParams; $binds = array(); $bc = -1; define('DATE_FORMAT', 'Y-m-d H:i'); //Set the interval if (isset($parameters['interval'])) { if (is_numeric($parameters['interval'])) { $interval = $parameters['interval']; } else { echo '<error>interval is not a number</error>'; die; } } else { // Default: downtimes declared in the last day $interval = '1'; } $nowMinusIntervalDays = new \DateTime(); $nowMinusIntervalDays->sub(new \DateInterval('P' . $interval . 'D')); $qb = $this->em->createQueryBuilder(); $qb->select('d', 'els', 'se', 's', 'st')->from('Downtime', 'd')->join('d.services', 'se')->leftJoin('d.endpointLocations', 'els')->join('se.serviceType', 'st')->join('se.parentSite', 's')->leftJoin('se.scopes', 'sc')->join('s.ngi', 'n')->join('s.country', 'c')->andWhere($qb->expr()->gt('d.insertDate', '?' . ++$bc))->orderBy('d.startDate', 'DESC'); //->orderBy('se.id', 'DESC'); //Bind interval days $binds[] = array($bc, $nowMinusIntervalDays); if (isset($parameters['id'])) { $qb->andWhere($qb->expr()->eq('d.id', '?' . ++$bc)); $binds[] = array($bc, $parameters['id']); } /*Pass parameters to the ParameterBuilder and allow it to add relevant where clauses * based on set parameters. */ $parameterBuilder = new ParameterBuilder($parameters, $qb, $this->em, $bc); //Get the result of the scope builder $qb = $parameterBuilder->getQB(); $bc = $parameterBuilder->getBindCount(); //Get the binds and store them in the local bind array - only runs if the returned value is an array foreach ((array) $parameterBuilder->getBinds() as $bind) { $binds[] = $bind; } //Run ScopeQueryBuilder regardless of if scope is set. $scopeQueryBuilder = new ScopeQueryBuilder(isset($parameters['scope']) ? $parameters['scope'] : null, isset($parameters['scope_match']) ? $parameters['scope_match'] : null, $qb, $this->em, $bc, 'Service', 'se'); //Get the result of the scope builder $qb = $scopeQueryBuilder->getQB(); $bc = $scopeQueryBuilder->getBindCount(); //Get the binds and store them in the local bind array only if any binds are fetched from scopeQueryBuilder foreach ((array) $scopeQueryBuilder->getBinds() as $bind) { $binds[] = $bind; } //Bind all variables $qb = $this->helpers->bindValuesToQuery($binds, $qb); $query = $qb->getQuery(); $this->query = $query; return $this->query; }
/** Creates the query by building on a queryBuilder object as * required by the supplied parameters */ public function createQuery() { $parameters = $this->validParams; $binds = array(); $bc = -1; $qb = $this->em->createQueryBuilder(); //Initialize base query $qb->select('s', 'n', 'r', 'u', 'rt')->from('Site', 's')->leftJoin('s.ngi', 'n')->leftJoin('s.country', 'c')->leftJoin('s.roles', 'r')->leftJoin('r.user', 'u')->leftJoin('r.roleType', 'rt')->orderBy('s.shortName', 'ASC'); /**This is used to filter the reults at the point * of building the XML to only show the correct roletypes. * Future work could see this build into the query. */ if (isset($parameters['roletype'])) { $this->roleT = $parameters['roletype']; } else { $this->roleT = '%%'; } /*Pass parameters to the ParameterBuilder and allow it to add relevant where clauses * based on set parameters. */ $parameterBuilder = new ParameterBuilder($parameters, $qb, $this->em, $bc); //Get the result of the scope builder $qb = $parameterBuilder->getQB(); $bc = $parameterBuilder->getBindCount(); //Get the binds and store them in the local bind array - only runs if the returned value is an array foreach ((array) $parameterBuilder->getBinds() as $bind) { $binds[] = $bind; } //Run ScopeQueryBuilder regardless of if scope is set. $scopeQueryBuilder = new ScopeQueryBuilder(isset($parameters['scope']) ? $parameters['scope'] : null, isset($parameters['scope_match']) ? $parameters['scope_match'] : null, $qb, $this->em, $bc, 'Site', 's'); //Get the result of the scope builder $qb = $scopeQueryBuilder->getQB(); $bc = $scopeQueryBuilder->getBindCount(); //Get the binds and store them in the local bind array only if any binds are fetched from scopeQueryBuilder foreach ((array) $scopeQueryBuilder->getBinds() as $bind) { $binds[] = $bind; } //Bind all variables $qb = $this->helpers->bindValuesToQuery($binds, $qb); //Get the dql query from the Query Builder object $query = $qb->getQuery(); $this->query = $query; return $this->query; }