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


PHP Builder::orWhere方法代码示例

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


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

示例1: applyOr

 /**
  * Call apply() within an "or" block
  * @param \Illuminate\Database\Query\Builder $query
  * @return \Illuminate\Database\Query\Builder $query
  */
 public function applyOr(\Illuminate\Database\Query\Builder $query)
 {
     $query->orWhere(function ($query) {
         $this->apply($query);
     });
     return $query;
 }
开发者ID:simmatrix,项目名称:laravel-query-builder-templates,代码行数:12,代码来源:AbstractScope.php

示例2: applyKeywordsFilter

 /**
  * {@inheritdoc}
  *
  * We will check for actual match rather than partial.
  */
 public function applyKeywordsFilter(Builder $builder, array $keywords)
 {
     foreach ($keywords as $keyword) {
         if (is_numeric($keyword)) {
             $builder->orWhere($this->id, '=', $keyword);
         }
     }
 }
开发者ID:guratr,项目名称:cruddy,代码行数:13,代码来源:Primary.php

示例3: process

 protected function process()
 {
     $this->method = 'GET';
     //database save
     switch ($this->action) {
         case "search":
             // prepare the WHERE clause
             foreach ($this->fields as $field) {
                 $field->getValue();
                 //$field->getNewValue();
                 //die( '..'.$field->value);
                 if ($field->value != "") {
                     if (strpos($field->name, "_copy") > 0) {
                         $name = substr($field->db_name, 0, strpos($field->db_name, "_copy"));
                     } else {
                         $name = $field->db_name;
                     }
                     $value = $field->value;
                     switch ($field->clause) {
                         case "like":
                             $this->query = $this->query->where($name, 'LIKE', '%' . $value . '%');
                             break;
                         case "orlike":
                             $this->query = $this->query->orWhere($name, 'LIKE', '%' . $value . '%');
                             break;
                         case "where":
                             $this->query = $this->query->where($name, $field->operator, $value);
                             break;
                         case "orwhere":
                             $this->query = $this->query->orWhere($name, $field->operator, $value);
                             break;
                     }
                 }
             }
         case "reset":
             $this->process_status = "show";
             return true;
             break;
         default:
             return false;
     }
 }
开发者ID:parabol,项目名称:laravel-cms,代码行数:42,代码来源:DataFilter.php

示例4: search

 /**
  * @param $search
  * @param $columns
  * @param \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder $query
  * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder
  */
 protected function search($search, $columns, $query)
 {
     if ($search) {
         $query->where(function ($query) use($search, $columns) {
             foreach ($columns as $column) {
                 $query->orWhere($column, 'LIKE', "%{$search}%");
             }
         });
     }
     return $query;
 }
开发者ID:snowfire,项目名称:sprinkles,代码行数:17,代码来源:Repository.php

示例5: scopeForModel

 /**
  * Constrain a query to an ability for a specific model.
  *
  * @param  \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder  $query
  * @param  \Illuminate\Database\Eloquent\Model  $model
  * @return void
  */
 public function scopeForModel($query, Model $model)
 {
     $query->where(function ($query) use($model) {
         $query->where('entity_type', $model->getMorphClass());
         $query->where(function ($query) use($model) {
             $query->whereNull('entity_id');
             if ($model->exists) {
                 $query->orWhere('entity_id', $model->getKey());
             }
         });
     });
 }
开发者ID:Gummibeer,项目名称:bouncer,代码行数:19,代码来源:Ability.php

示例6: scopeForModel

 /**
  * Constrain a query to an permission for a specific model.
  *
  * @param  \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder  $query
  * @param  \Illuminate\Database\Eloquent\Model|string  $model
  * @param  bool  $strict
  * @return void
  */
 public function scopeForModel($query, $model, $strict = false)
 {
     $model = is_string($model) ? new $model() : $model;
     $query->where(function ($query) use($model, $strict) {
         $query->where('entity_type', $model->getMorphClass());
         $query->where(function ($query) use($model, $strict) {
             // If the model does not exist, we want to search for blanket permissions
             // that cover all instances of this model. If it does exist, we only
             // want to find blanket permissions if we're not using strict mode.
             if (!$model->exists || !$strict) {
                 $query->whereNull('entity_id');
             }
             if ($model->exists) {
                 $query->orWhere('entity_id', $model->getKey());
             }
         });
     });
 }
开发者ID:devonzara,项目名称:bouncer,代码行数:26,代码来源:Permission.php

示例7: addFilterQuery

 /**
  * Add global filter to query builder
  * @param \Illuminate\Database\Query\Builder $query object is by reference
  */
 protected function addFilterQuery($query)
 {
     if (isset($this->filter)) {
         $likable = null;
         $table = $this->attributes('table');
         $map = $this->attributes('map');
         foreach ($map as $property => $options) {
             if (isset($options['column']) && isset($options['likable']) && $options['likable'] == true) {
                 $likable[] = $table . "." . $options['column'];
             }
         }
         if (isset($likable)) {
             $query->where(function ($query) use($likable) {
                 foreach ($likable as $like) {
                     $query->orWhere($this->map($like), 'like', "%{$this->filter}%");
                 }
             });
         } else {
             // No columns are likable, just use primary with = (not like)
             $primary = $this->attributes('primary');
             if (isset($primary)) {
                 $query->where($primary, $this->filter);
             }
         }
     }
 }
开发者ID:mreschke,项目名称:repository,代码行数:30,代码来源:DbStore.php

示例8: filterQueryKanji

 /**
  * @param string $kanji
  * @param \Illuminate\Database\Query\Builder $q
  * @param string $colName
  */
 public static function filterQueryKanji($kanji, $q, $colName)
 {
     if (isset($kanji)) {
         $decoded_kanji = rawurldecode($kanji);
         if ($kanji !== '_' && $kanji !== '-') {
             $q->orWhere($colName, 'like', '%' . $decoded_kanji . '%');
         }
     }
 }
开发者ID:pazjacket,项目名称:YU81-_-zip-address-util,代码行数:14,代码来源:Address.php

示例9: orWhere

 /**
  * Add an "or where" clause to the query.
  *
  * @param string $column
  * @param string $operator
  * @param mixed $value
  * @return \Illuminate\Database\Query\Builder|static 
  * @static 
  */
 public static function orWhere($column, $operator = null, $value = null)
 {
     return \Illuminate\Database\Query\Builder::orWhere($column, $operator, $value);
 }
开发者ID:jorzhikgit,项目名称:MLM-Nexus,代码行数:13,代码来源:_ide_helper.php

示例10: isReservedButExpired

 /**
  * Modify the query to check for jobs that are reserved but have expired.
  *
  * @param  \Illuminate\Database\Query\Builder  $query
  * @return void
  */
 protected function isReservedButExpired($query)
 {
     $expiration = Carbon::now()->subSeconds($this->expire)->getTimestamp();
     $query->orWhere(function ($query) use($expiration) {
         $query->where('reserved', 1);
         $query->where('reserved_at', '<=', $expiration);
     });
 }
开发者ID:timpressive,项目名称:art-auction,代码行数:14,代码来源:DatabaseQueue.php

示例11: searches

 /**
  * 주어진 query에 like 검색 조건을 추가한다.
  *
  * @param Builder $query    검색조건을 적용할 query
  * @param mixed   $searches 검색할 조건
  *
  * @return Builder
  */
 protected function searches($query, $searches)
 {
     foreach ($searches as $field => $value) {
         $fields = explode(',', $field);
         $query->where(array_shift($fields), 'like', '%' . $value . '%');
         foreach ($fields as $f) {
             $query->orWhere($f, 'like', '%' . $value . '%');
         }
     }
     return $query;
 }
开发者ID:mint-soft-com,项目名称:xpressengine,代码行数:19,代码来源:DatabaseRepositoryTrait.php

示例12: applySearch

 /**
  * Apply search to the query.
  *
  * @param Builder $query
  */
 protected function applySearch(Builder $query)
 {
     $search = Input::get('search.value');
     if (is_null($search)) {
         return;
     }
     $query->where(function ($query) use($search) {
         $columns = $this->columns();
         foreach ($columns as $column) {
             if ($column instanceof String) {
                 $name = $column->name();
                 if ($this->repository->hasColumn($name)) {
                     $query->orWhere($name, 'like', '%' . $search . '%');
                 }
             }
         }
     });
 }
开发者ID:KodiComponents,项目名称:module-sleepingowl,代码行数:23,代码来源:DisplayDatatablesAsync.php

示例13: orWhere

 /**
  * @param \Illuminate\Database\Query\Builder $query
  * @param string $field
  * @param array $rule
  */
 protected function orWhere($query, $field, $rule)
 {
     $configs = $this->configs($rule);
     $value = trim($this->data->get($configs->get('get', $field), ''));
     if ($value == '') {
         return;
     }
     $condition = $configs->get('options');
     $condition = array_shift($condition);
     if (in_array($condition, ['=', '<', '>', '<>', '<=', '>='])) {
         $query->orWhere($field, $condition, $value);
     } elseif ($condition == '%like%') {
         $query->orWhere($field, 'like', "%{$value}%");
     } elseif ($condition == 'like%') {
         $query->orWhere($field, 'like', "{$value}%");
     } elseif ($condition == '%like') {
         $query->orWhere($field, 'like', "%{$value}");
     } elseif ($condition == 'like') {
         $query->orWhere($field, 'like', "{$value}");
     }
 }
开发者ID:alex-oliveira,项目名称:ao-scrud,代码行数:26,代码来源:RulesCriteria.php

示例14: buildWildcardQueryFilterWithKeyword

 /**
  * Build wildcard query filter by keyword.
  *
  * @param  \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder  $query
  * @param  string  $field
  * @param  array  $keyword
  * @param  string  $group
  *
  * @return void
  */
 protected function buildWildcardQueryFilterWithKeyword($query, $field, array $keyword = [], $group = 'where')
 {
     $callback = function ($query) use($field, $keyword) {
         foreach ($keyword as $key) {
             $query->orWhere($field, 'LIKE', $key);
         }
     };
     $query->{$group}($callback);
 }
开发者ID:DavidIWilson,项目名称:site1,代码行数:19,代码来源:QueryFilterTrait.php

示例15: process

 protected function process()
 {
     $this->method = 'GET';
     //database save
     switch ($this->action) {
         case "search":
             // prepare the WHERE clause
             foreach ($this->fields as $field) {
                 $field->getValue();
                 $field->getNewValue();
                 $value = $field->new_value;
                 //query scope
                 $query_scope = $field->query_scope;
                 $query_scope_params = $field->query_scope_params;
                 if ($query_scope) {
                     if (is_a($query_scope, '\\Closure')) {
                         array_unshift($query_scope_params, $value);
                         array_unshift($query_scope_params, $this->query);
                         $this->query = call_user_func_array($query_scope, $query_scope_params);
                     } elseif (isset($this->model) && method_exists($this->model, "scope" . $query_scope)) {
                         $query_scope = "scope" . $query_scope;
                         array_unshift($query_scope_params, $value);
                         array_unshift($query_scope_params, $this->query);
                         $this->query = call_user_func_array([$this->model, $query_scope], $query_scope_params);
                     }
                     continue;
                 }
                 //detect if where should be deep (on relation)
                 $deep_where = false;
                 if (isset($this->model) && $field->relation != null) {
                     $rel_type = get_class($field->relation);
                     if (is_a($field->relation, 'Illuminate\\Database\\Eloquent\\Relations\\HasOne') || is_a($field->relation, 'Illuminate\\Database\\Eloquent\\Relations\\HasMany') || is_a($field->relation, 'Illuminate\\Database\\Eloquent\\Relations\\BelongsTo') || is_a($field->relation, 'Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany')) {
                         if (is_a($field->relation, 'Illuminate\\Database\\Eloquent\\Relations\\BelongsTo') and in_array($field->type, array('select', 'radiogroup', 'autocomplete'))) {
                             $deep_where = false;
                         } else {
                             $deep_where = true;
                         }
                     }
                 }
                 if ($value != "" or is_array($value) and count($value)) {
                     if (strpos($field->name, "_copy") > 0) {
                         $name = substr($field->db_name, 0, strpos($field->db_name, "_copy"));
                     } else {
                         $name = $field->db_name;
                     }
                     //$value = $field->value;
                     if ($deep_where) {
                         //exception for multiple value fields on BelongsToMany
                         if (is_a($field->relation, 'Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany') || is_a($field->relation, 'Illuminate\\Database\\Eloquent\\Relations\\BelongsTo') and in_array($field->type, array('tags', 'checks', 'multiselect'))) {
                             $values = explode($field->serialization_sep, $value);
                             if ($field->clause == 'wherein') {
                                 $this->query = $this->query->whereHas($field->rel_name, function ($q) use($field, $values) {
                                     $q->whereIn($field->rel_fq_key, $values);
                                 });
                             }
                             if ($field->clause == 'where') {
                                 foreach ($values as $v) {
                                     $this->query = $this->query->whereHas($field->rel_name, function ($q) use($field, $v) {
                                         $q->where($field->rel_fq_key, '=', $v);
                                     });
                                 }
                             }
                             continue;
                         }
                         switch ($field->clause) {
                             case "like":
                                 $this->query = $this->query->whereHas($field->rel_name, function ($q) use($field, $value) {
                                     $q->where($field->rel_field, 'LIKE', '%' . $value . '%');
                                 });
                                 break;
                             case "orlike":
                                 $this->query = $this->query->orWhereHas($field->rel_name, function ($q) use($field, $value) {
                                     $q->where($field->rel_field, 'LIKE', '%' . $value . '%');
                                 });
                                 break;
                             case "where":
                                 $this->query = $this->query->whereHas($field->rel_name, function ($q) use($field, $value) {
                                     $q->where($field->rel_field, $field->operator, $value);
                                 });
                                 break;
                             case "orwhere":
                                 $this->query = $this->query->orWhereHas($field->rel_name, function ($q) use($field, $value) {
                                     $q->where($field->rel_field, $field->operator, $value);
                                 });
                                 break;
                             case "wherebetween":
                                 $values = explode($field->serialization_sep, $value);
                                 $this->query = $this->query->whereHas($field->rel_name, function ($q) use($field, $values) {
                                     if ($values[0] != '' and $values[1] == '') {
                                         $q->where($field->rel_field, ">=", $values[0]);
                                     } elseif ($values[0] == '' and $values[1] != '') {
                                         $q->where($field->rel_field, "<=", $values[1]);
                                     } elseif ($values[0] != '' and $values[1] != '') {
                                         //we avoid "whereBetween" because a bug in laravel 4.1
                                         $q->where(function ($query) use($field, $values) {
                                             return $query->where($field->rel_field, ">=", $values[0])->where($field->rel_field, "<=", $values[1]);
                                         });
                                     }
                                 });
                                 break;
//.........这里部分代码省略.........
开发者ID:maxmirazh33,项目名称:rapyd-laravel,代码行数:101,代码来源:DataFilter.php


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