/** 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; }