本文整理汇总了PHP中Doctrine\DBAL\Query\QueryBuilder::andWhere方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::andWhere方法的具体用法?PHP QueryBuilder::andWhere怎么用?PHP QueryBuilder::andWhere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Query\QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::andWhere方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: finalizeQuery
public function finalizeQuery(\Doctrine\DBAL\Query\QueryBuilder $query)
{
$paramcount = 0;
if (isset($this->gID) && $this->gID > 0) {
$query->where('gID = ?')->setParameter($paramcount++, $this->gID);
}
switch ($this->sortBy) {
case "alpha":
$query->orderBy('pName', 'ASC');
break;
case "date":
$query->orderBy('pDateAdded', 'DESC');
break;
}
switch ($this->featured) {
case "featured":
$query->andWhere("pFeatured = 1");
break;
case "nonfeatured":
$query->andWhere("pFeatured = 0");
break;
}
if ($this->activeOnly) {
$query->andWhere("pActive = 1");
}
if ($this->search) {
$query->andWhere('pName like ?')->setParameter($paramcount++, '%' . $this->search . '%');
}
return $query;
}
示例2: apply
/**
* {@inheritdoc}
*/
public function apply($fromAlias, $fromIdentifier, $resourcePrefix, array $requesterIdentifiers, $mask, array $orX = [])
{
$this->queryBuilder->leftJoin($fromAlias, $this->getAclSchema()->getPermissionsTableName(), 'acl_p', 'acl_p.resource = ' . $this->connection->getDatabasePlatform()->getConcatExpression(':acl_prefix', $fromAlias . '.' . $fromIdentifier));
$orX[] = 'acl_p.requester IN (:acl_identifiers) AND :acl_mask = (acl_p.mask & :acl_mask)';
$this->queryBuilder->andWhere(implode(' OR ', $orX));
$this->queryBuilder->setParameter('acl_prefix', $resourcePrefix, \PDO::PARAM_STR)->setParameter('acl_identifiers', $requesterIdentifiers, Connection::PARAM_STR_ARRAY)->setParameter('acl_mask', $mask, \PDO::PARAM_INT);
return $this->queryBuilder;
}
示例3: filter
/**
* @deprecated
*/
public function filter($field, $value, $comparison = '=')
{
if ($field == false) {
$this->query->andWhere($value);
// ugh
} else {
$this->query->andWhere(implode(' ', array($field, $comparison, $this->query->createNamedParameter($value))));
}
}
示例4: finalizeQuery
public function finalizeQuery(\Doctrine\DBAL\Query\QueryBuilder $query)
{
if (!$this->includeInactiveUsers) {
$query->andWhere('u.uIsActive = :uIsActive');
$query->setParameter('uIsActive', true);
}
if (!$this->includeUnvalidatedUsers) {
$query->andWhere('u.uIsValidated != 0');
}
return $query;
}
示例5: restrict
/**
* {@inheritdoc}
*/
public function restrict($expression, $condition = DataSourceInterface::CONDITION_AND)
{
switch ($condition) {
case DataSourceInterface::CONDITION_AND:
$this->queryBuilder->andWhere($expression);
break;
case DataSourceInterface::CONDITION_OR:
$this->queryBuilder->orWhere($expression);
break;
}
}
示例6: buildQuery
/**
* {@inheritdoc}
*/
public function buildQuery(QueryBuilder $queryBuilder, array $values = array())
{
if (!array_key_exists('salary', $values)) {
return;
}
//Switch min and max salary if user has inverted the fields
if (isset($values['salary']['min']) && isset($values['salary']['max']) && $values['salary']['max'] < $values['salary']['min']) {
list($values['salary']['min'], $values['salary']['max']) = [$values['salary']['max'], $values['salary']['min']];
}
if (isset($values['salary']['min'])) {
$queryBuilder->andWhere('response.grossAnnualSalary >= :minSalary')->setParameter('minSalary', $values['salary']['min']);
}
if (isset($values['salary']['max'])) {
$queryBuilder->andWhere('response.grossAnnualSalary <= :maxSalary')->setParameter('maxSalary', $values['salary']['max']);
}
}
示例7: incorporateDbalQueryBuilder
/**
* @internal
*/
private function incorporateDbalQueryBuilder(QueryBuilder $qb, FilterInterface $filter)
{
$criteria = $this->getFilteringCriteria($filter);
// extraindo os rootAliases, pois o DBAL\QueryBuilder não tem
$fromPart = $qb->getQueryPart('from');
$rootAliases = array();
foreach ($fromPart as $part) {
$rootAliases[] = $part['alias'];
}
$visitor = new DbalQueryExpressionVisitor($qb->getConnection(), $rootAliases, $this->fieldMap);
if ($whereExpression = $criteria->getWhereExpression()) {
$qb->andWhere($visitor->dispatch($whereExpression));
$qb->setParameters($visitor->getParameters());
}
if ($criteria->getOrderings()) {
foreach ($criteria->getOrderings() as $sort => $order) {
$qb->addOrderBy($visitor->getFieldName($sort), $order);
}
}
if (($firstResult = $criteria->getFirstResult()) !== null) {
$qb->setFirstResult($firstResult);
}
if (($maxResults = $criteria->getMaxResults()) !== null) {
$qb->setMaxResults($maxResults);
}
}
示例8: match
public function match(QueryBuilder $qb)
{
if ($this->has('username')) {
$qb->andWhere('u.username = :username');
$qb->setParameter('username', $this->get('username'));
}
}
示例9: where
public function where($column, $operator = null, $value = null, $boolean = 'and')
{
$args = func_get_args();
if (count($args) == 1) {
parent::where($args[0]);
return $this;
}
$column = $args[0];
$boolean = 'and';
$operator = '=';
if (count($args) == 2) {
$value = $args[1];
}
if (count($args) == 3) {
$operator = $args[1];
$value = $args[2];
}
if (count($args) == 4) {
$operator = $args[1];
$value = $args[2];
$boolean = $args[3];
}
if (is_array($value)) {
$operator = $operator == '=' ? 'in' : 'notIn';
$where_clause = $this->expr()->{$operator}($column, parent::createNamedParameter($value, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY));
} else {
$where_clause = $column . $operator . parent::createNamedParameter($value);
}
if ($boolean == 'and') {
parent::andWhere($where_clause);
} elseif ($boolean == 'or') {
parent::orWhere($where_clause);
}
return $this;
}
示例10: filters
/**
* @param $tableName
* @param $conditions
*
* @return array
*
* @throws LookupError
*
* @since 1.1.0
*
* @author Eddilbert Macharia (http://eddmash.com) <edd.cowan@gmail.com>
*/
public static function filters(QueryBuilder $queryBuilder, $conditions)
{
// default lookup is equal
$lookup = 'eq';
// we add the or conditions afterwards to avoid them being mistaken for "and" conditions when they come first
$or_combine = [];
$and_combine = [];
// create where clause from the conditions given
foreach ($conditions as $condition) {
foreach ($condition as $key => $value) {
$column = self::getLookupColumn($key);
$lookup = self::getLookUP($key);
$value = self::prepareValue($value, $lookup);
echo self::$lookuOptions[$lookup] . '<br>';
echo $queryBuilder->createNamedParameter($value) . '<br>';
echo $value . '<br>';
$lookupCondition = sprintf(self::$lookuOptions[$lookup], $queryBuilder->createNamedParameter($value));
$queryString = sprintf('%s %s', $column, $lookupCondition);
if (self::combine($key) === self::$or) {
$queryBuilder->orWhere($queryString);
} else {
$queryBuilder->andWhere($queryString);
}
}
}
}
示例11: buildQuery
/**
* {@inheritdoc}
*/
public function buildQuery(QueryBuilder $queryBuilder, array $values = array())
{
if (!array_key_exists($this->getName(), $values) || 0 === count($values[$this->getName()])) {
return;
}
$queryBuilder->andWhere($queryBuilder->expr()->in('response.companyType', $values[$this->getName()]));
}
示例12: buildQuery
/**
* Builds the raw query
*
* @return void
*/
protected function buildQuery()
{
$this->queryBuilder = $this->connection->createQueryBuilder();
$this->queryBuilder->select((array) $this->conf->select);
/*
* Main table
*/
$this->queryBuilder->from($this->conf->from->name, $this->conf->from->alias);
/*
* Inner join, right join, left join
*/
$joinTypes = ['innerJoin', 'leftJoin', 'rightJoin'];
foreach ($joinTypes as $joinType) {
if (isset($this->conf->{$joinType})) {
$joins = $this->conf->{$joinType};
$this->buildJoins($joinType, $joins);
}
}
/*
* Condition
*/
if (isset($this->conf->where)) {
foreach ($this->conf->where as $where) {
$this->queryBuilder->andWhere($where);
}
}
}
示例13: finalizeQuery
public function finalizeQuery(\Doctrine\DBAL\Query\QueryBuilder $query)
{
$paramcount = 0;
if (isset($this->gID) && $this->gID > 0) {
$query->where('gID = ?')->setParameter($paramcount++, $this->gID);
}
switch ($this->sortBy) {
case "alpha":
$query->orderBy('drName', 'ASC');
break;
}
if ($this->search) {
$query->andWhere('drName like ?')->setParameter($paramcount++, '%' . $this->search . '%');
}
$query->andWhere('drDeleted is NULL');
return $query;
}
示例14: finalizeQuery
public function finalizeQuery(\Doctrine\DBAL\Query\QueryBuilder $query)
{
if (!$this->includeAllGroups) {
$query->andWhere('g.gID > :minGroupID');
$query->setParameter('minGroupID', REGISTERED_GROUP_ID);
}
return $query;
}
示例15: parse
/**
* Parses the `CriteriaExpression` and appropriately configures the passed query builder.
*
* @param QueryBuilder $queryBuilder Query builder to be configured.
* @param CriteriaExpression|null $criteria Criteria to be parsed.
*
* @return QueryBuilder
*/
public function parse(QueryBuilder $queryBuilder, CriteriaExpression $criteria = null)
{
if (!$criteria || count($criteria->getCriteria()) === 0) {
return $queryBuilder;
}
$queryBuilder->andWhere($this->parseCriteria($queryBuilder, $criteria));
return $queryBuilder;
}