当前位置: 首页>>代码示例>>PHP>>正文


PHP QueryBuilder::where方法代码示例

本文整理汇总了PHP中QueryBuilder::where方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::where方法的具体用法?PHP QueryBuilder::where怎么用?PHP QueryBuilder::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QueryBuilder的用法示例。


在下文中一共展示了QueryBuilder::where方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: is

 /**
  * {@inheritDoc}
  */
 public function is($number)
 {
     if ($this->currentColumnRaw === $this->columns['group']) {
         $this->eventQuery->where('group')->is($number);
     }
     return parent::is($number);
 }
开发者ID:kleitz,项目名称:bzion,代码行数:10,代码来源:MessageQueryBuilder.php

示例2: scopeArchiveFiltered

 /**
  * Get latest posts filtered by year and month?
  *
  * @param QueryBuilder $query
  * @param int $year
  * @param int $month
  */
 public function scopeArchiveFiltered($query, $year, $month)
 {
     return $query->where(function ($query) use($year, $month) {
         if ($year) {
             $query->where(DB::raw('YEAR(created_at)'), $year);
         }
         if ($month) {
             $query->where(DB::raw('MONTH(created_at)'), $month);
         }
     })->orderBy('posts.created_at', 'DESC');
 }
开发者ID:Erbenos,项目名称:laravel-blog,代码行数:18,代码来源:Post.php

示例3: playerQuery

 private function playerQuery(\QueryBuilder $query, Request $request)
 {
     if ($team = $request->query->get('team')) {
         $query->where('team')->is($team);
     }
     return $query->getArray(array('name', 'outdated'));
 }
开发者ID:allejo,项目名称:bzion,代码行数:7,代码来源:SearchController.php

示例4: scopeIdOrUuid

 /**
  * Method for searching model by Id or Uuid
  * @param  QueryBuilder $query
  * @param  Int|Uuid $value
  * @return Illuminate\Database\Eloquent\Builder
  */
 public function scopeIdOrUuid($query, $value)
 {
     if (!Uuid::isValid($value) && !is_numeric($value)) {
         throw (new ModelNotFoundException())->setModel(get_class($this));
     }
     return $query->where($this->primaryKey, '=', $value)->orWhere('uuid', '=', $value);
 }
开发者ID:beautycoding,项目名称:modelutils,代码行数:13,代码来源:UuidModel.php

示例5: doFiltering

 /**
  * Datatables filtering
  */
 public function doFiltering()
 {
     $this->query->where(function ($query) {
         $columns = $this->input['columns'];
         for ($i = 0, $c = count($columns); $i < $c; $i++) {
             if (!$this->isColumnSearchable($columns, $i, false)) {
                 continue;
             }
             $column = $this->setupColumn($columns, $i);
             $keyword = $this->setupKeyword($this->input['search']['value']);
             if (isset($this->filter_columns[$column])) {
                 $method = $this->getOrMethod($this->filter_columns[$column]['method']);
                 $parameters = $this->filter_columns[$column]['parameters'];
                 $this->compileFilterColumn($method, $parameters, $column);
             } else {
                 $this->compileGlobalSearch($query, $column, $keyword);
             }
         }
     });
 }
开发者ID:Kirylka,项目名称:Scaffold,代码行数:23,代码来源:BaseEngine.php

示例6: testWhere13

 /**
  * Generated from @assert where(array('ip', 'NOT IN', array('', '192.168.1.104')))->text() [==] " WHERE `ip` NOT IN ('', :ip1)".
  *
  * @covers Kotchasan\Database\QueryBuilder::where
  */
 public function testWhere13()
 {
     $this->assertEquals(" WHERE `ip` NOT IN ('', :ip1)", $this->object->where(array('ip', 'NOT IN', array('', '192.168.1.104')))->text());
 }
开发者ID:goragod,项目名称:kotchasan,代码行数:9,代码来源:QueryBuilderTest.php

示例7: handleFiltering

 /**
  * We process filtering on this query if there
  * is any $this->Input->get() found for dvs-filters
  * this is used in Sortable\Database\Eloquent\Builder.paginate
  *
  * It's magic... really.
  *
  * @param  QueryBuilder $query
  * @param  Eloquent     $model
  * @return  void
  */
 public function handleFiltering(&$query, $model)
 {
     $filters = $this->Input->get('dvs-filters', array());
     foreach ($filters as $filterName => $filterValue) {
         $query->where($filterName, 'LIKE', "%{$filterValue}%");
     }
 }
开发者ID:devisephp,项目名称:cms,代码行数:18,代码来源:Sort.php

示例8: mergeWhereInto

 /**
  * Merge this QueryBuilder's WHERE into the given QueryBuilder.
  *
  * @param  QueryBuilder $QueryBuilder to merge into
  * @return QueryBuilder
  */
 public function mergeWhereInto(QueryBuilder $QueryBuilder)
 {
     foreach ($this->where as $currentWhere) {
         // Handle open/close brackets differently than other criteria.
         if (array_key_exists('bracket', $currentWhere)) {
             if (strcmp($currentWhere['bracket'], self::BRACKET_OPEN) == 0) {
                 $QueryBuilder->openWhere($currentWhere['connector']);
             } else {
                 $QueryBuilder->closeWhere();
             }
         } else {
             $QueryBuilder->where($currentWhere['column'], $currentWhere['value'], $currentWhere['operator'], $currentWhere['connector']);
         }
     }
     return $QueryBuilder;
 }
开发者ID:netconstructor,项目名称:QueryBuilder-1,代码行数:22,代码来源:QueryBuilder.php

示例9: testWhere8

 /**
  * Generated from @assert where(array('id', 'IN', array(1, 2, '3')))->text() [==] " WHERE `id` IN (:id0, :id1, :id2)".
  *
  * @covers Core\Database\QueryBuilder::where
  */
 public function testWhere8()
 {
     $this->assertEquals(" WHERE `id` IN (:id0, :id1, :id2)", $this->object->where(array('id', 'IN', array(1, 2, '3')))->text());
 }
开发者ID:kongvut,项目名称:kotchasan,代码行数:9,代码来源:querybuilderTest.php

示例10: findByPk

 /**
  * Initiates a find by PK query
  *
  * @param $pk
  * @param $select
  * @return QueryBuilder
  */
 public static function findByPk($pk, $select = null)
 {
     $instance = self::createInstance();
     $instance->getFields();
     if ($instance->primaryKey == null) {
         return null;
     }
     $query = new QueryBuilder($instance->getTable(), 'SELECT');
     if ($select != null) {
         $query->select($select);
     }
     $query->where([$instance->primaryKey => $pk]);
     return $query->one();
 }
开发者ID:jellingsen,项目名称:db-models,代码行数:21,代码来源:BaseModel.php

示例11: editOptionById

 /**
  * Edit an already created answer option
  *
  * @param integer $profile_id
  * @param string $new_answer
  * @param integer $sort_id
  */
 public function editOptionById($profile_id, $new_answer, $sort_id = null)
 {
     $additional_sql = '';
     $qb = new QueryBuilder();
     $qb->update(Tbl::get('TBL_PROFILE_KEYS'))->set(new Field('value'), $new_answer);
     if (empty($profile_id) or !is_numeric($profile_id)) {
         throw new InvalidArgumentException("\$profile have to be numeric id of the profile");
     }
     if (empty($new_answer)) {
         throw new InvalidArgumentException("\$new_answer have be not null string");
     }
     if (!empty($sort_id) and !is_numeric($sort_id)) {
         throw new InvalidArgumentException("\$sort_id have to have numeric value");
     } else {
         $qb->set(new Field('sort_id'), $sort_id);
         $additional_sql .= ", `sort_id`='{$sort_id}'";
     }
     $qb->where($qb->expr()->equal(new Field('id'), $profile_id));
     $this->query->exec($qb->getSQL());
 }
开发者ID:Welvin,项目名称:stingle,代码行数:27,代码来源:Profile.class.php

示例12: updateUserProperties

 /**
  * Updated User Properties
  * 
  * @param UserProperties $properties
  * @return integer Affected
  */
 protected function updateUserProperties(UserProperties $properties)
 {
     if (count($this->config->userPropertiesMap->toArray()) > 0) {
         $qb = new QueryBuilder();
         $qb->update(Tbl::get('TBL_USERS_PROPERTIES'));
         foreach ($this->config->userPropertiesMap as $objectKey => $dbKey) {
             $qb->set(new Field($dbKey), $properties->{$objectKey});
         }
         $qb->where($qb->expr()->equal(new Field('user_id'), $properties->userId));
         return $this->query->exec($qb->getSQL())->affected();
     }
     return 0;
 }
开发者ID:Welvin,项目名称:stingle,代码行数:19,代码来源:UserManager.class.php

示例13: define

if (!defined('MYSQL_PREFIX')) {
    define('MYSQL_PREFIX', 'prism_');
    // Old config files may not have the constant defined yet.
}
// Build query
$qb = new QueryBuilder();
$qb->select('id, epoch, action, player, world, x, y, z, block_id, block_subid, old_block_id, old_block_subid, data');
$qb->from(MYSQL_PREFIX . 'data', 'd');
$qb->join('INNER JOIN ' . MYSQL_PREFIX . 'players p ON p.player_id = d.player_id');
$qb->join('INNER JOIN ' . MYSQL_PREFIX . 'actions a ON a.action_id = d.action_id');
$qb->join('INNER JOIN ' . MYSQL_PREFIX . 'worlds w ON w.world_id = d.world_id');
$qb->join('LEFT JOIN ' . MYSQL_PREFIX . 'data_extra ex ON ex.data_id = d.id');
// World
if (!$peregrine->post->isEmpty('world')) {
    $world = explode(",", $peregrine->post->getUsername('world'));
    $qb->where(QueryBuilder::buildOrQuery('w.world', $world));
}
// Coordinates
if (!$peregrine->post->isEmpty('x', false, false) && !$peregrine->post->isInt('y', false, false) && !$peregrine->post->isInt('z', false, false)) {
    $x = $peregrine->post->getInt('x');
    $y = $peregrine->post->getInt('y');
    $z = $peregrine->post->getInt('z');
    if (!$peregrine->post->isInt('radius', false, false)) {
        $radius = $peregrine->post->getInt('radius');
        $qb->where('( d.x BETWEEN ' . ($x - $radius) . ' AND ' . ($x + $radius) . ' )');
        $qb->where('( d.y BETWEEN ' . ($y - $radius) . ' AND ' . ($y + $radius) . ' )');
        $qb->where('( d.z BETWEEN ' . ($z - $radius) . ' AND ' . ($z + $radius) . ' )');
    } else {
        $qb->where('d.x = ' . $x);
        $qb->where('d.y = ' . $y);
        $qb->where('d.z = ' . $z);
开发者ID:Quartzcraft,项目名称:Website,代码行数:31,代码来源:query.php

示例14: setQueriyBuilderConditons

 /**
  * Set the query builder object with conditions.
  *
  * @param QueryBuilder $qb
  * @param string $code the currency code
  * @param \DateTime $datetime the searched datetime
  */
 private function setQueriyBuilderConditons(&$qb, $code, \DateTime $datetime)
 {
     //create datetime intervallum
     $datetimeCopy = clone $datetime;
     $start = $datetime->setTime(0, 0, 0);
     $end = $datetimeCopy->setTime(23, 59, 59);
     //set the common conditions.
     $qb->where('r.currencyCode = :code')->andWhere('r.created >= :start AND r.created <= :end')->setParameter('code', $code)->setParameter('start', $start)->setParameter('end', $end);
 }
开发者ID:hkmshb,项目名称:OpitHrm,代码行数:16,代码来源:RateRepository.php


注:本文中的QueryBuilder::where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。