Пример #1
0
 /**
  * {@inheritDoc}
  */
 public function is($number)
 {
     if ($this->currentColumnRaw === $this->columns['group']) {
         $this->eventQuery->where('group')->is($number);
     }
     return parent::is($number);
 }
Пример #2
0
 /**
  * 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');
 }
Пример #3
0
 private function playerQuery(\QueryBuilder $query, Request $request)
 {
     if ($team = $request->query->get('team')) {
         $query->where('team')->is($team);
     }
     return $query->getArray(array('name', 'outdated'));
 }
Пример #4
0
 /**
  * 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);
 }
Пример #5
0
 /**
  * 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);
             }
         }
     });
 }
Пример #6
0
 /**
  * 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());
 }
Пример #7
0
 /**
  * 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;
 }
Пример #9
0
 /**
  * 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());
 }
Пример #10
0
 /**
  * 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();
 }
Пример #11
0
 /**
  * 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());
 }
Пример #12
0
 /**
  * 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;
 }
Пример #13
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);
Пример #14
0
 /**
  * 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);
 }