/** * {@inheritDoc} */ public function is($number) { if ($this->currentColumnRaw === $this->columns['group']) { $this->eventQuery->where('group')->is($number); } return parent::is($number); }
/** * 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'); }
private function playerQuery(\QueryBuilder $query, Request $request) { if ($team = $request->query->get('team')) { $query->where('team')->is($team); } return $query->getArray(array('name', 'outdated')); }
/** * 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); }
/** * 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); } } }); }
/** * 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()); }
/** * 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}%"); } }
/** * 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; }
/** * 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()); }
/** * 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(); }
/** * 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()); }
/** * 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; }
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);
/** * 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); }