當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Builder::whereRaw方法代碼示例

本文整理匯總了PHP中Builder::whereRaw方法的典型用法代碼示例。如果您正苦於以下問題:PHP Builder::whereRaw方法的具體用法?PHP Builder::whereRaw怎麽用?PHP Builder::whereRaw使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Builder的用法示例。


在下文中一共展示了Builder::whereRaw方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: doColumnSearch

 /**
  * Perform column search
  *
  * @return void
  */
 public function doColumnSearch()
 {
     $input = $this->input;
     $columns = $input['columns'];
     // if older version, set the column name to query's fields
     // or if new version but does not use mData support
     if (!$this->new_version or !$this->mDataSupport and $this->new_version) {
         for ($i = 0; $i < count($columns); $i++) {
             if (!isset($this->columns[$i])) {
                 continue;
             }
             $columns[$i]['name'] = $this->columns[$i];
             if (stripos($columns[$i]['name'], ' AS ') !== false or $columns[$i]['name'] instanceof Expression) {
                 $columns[$i]['name'] = '';
                 $columns[$i]['searchable'] = false;
                 $columns[$i]['orderable'] = false;
             }
         }
     }
     for ($i = 0, $c = count($columns); $i < $c; $i++) {
         if ($columns[$i]['searchable'] == "true" and !empty($columns[$i]['search']['value']) and !empty($columns[$i]['name'])) {
             $column = $columns[$i]['name'];
             $keyword = $this->setupKeyword($columns[$i]['search']['value']);
             // wrap column possibly allow reserved words to be used as column
             $column = $this->wrapColumn($column);
             if ($this->isCaseInsensitive()) {
                 $this->query->whereRaw('LOWER(' . $column . ') LIKE ?', [strtolower($keyword)]);
             } else {
                 $col = strstr($column, '(') ? $this->connection->raw($column) : $column;
                 $this->query->where($col, 'LIKE', $keyword);
             }
         }
     }
 }
開發者ID:testoodoo,項目名稱:OoodooSiteUp,代碼行數:39,代碼來源:Datatables.php

示例2: doColumnSearch

 /**
  * Perform column search
  *
  * @param  array $columns
  * @return void
  */
 public function doColumnSearch(array $columns)
 {
     for ($i = 0, $c = count($columns); $i < $c; $i++) {
         if ($columns[$i]['searchable'] == "true" and !empty($columns[$i]['search']['value']) and !empty($columns[$i]['name'])) {
             $column = $columns[$i]['name'];
             $keyword = $this->setupKeyword($columns[$i]['search']['value']);
             // wrap column possibly allow reserved words to be used as column
             $column = $this->wrapColumn($column);
             if ($this->isCaseInsensitive()) {
                 $this->query->whereRaw('LOWER(' . $column . ') LIKE ?', [strtolower($keyword)]);
             } else {
                 $col = strstr($column, '(') ? $this->connection->raw($column) : $column;
                 $this->query->where($col, 'LIKE', $keyword);
             }
         }
     }
 }
開發者ID:kimnv57,項目名稱:laravel-simple-api-ueter-aide,代碼行數:23,代碼來源:Datatables.php

示例3: applyScopeToQuery

 /**
  * Applies a filter scope constraints to a DB query.
  * @param  string $scope
  * @param  Builder $query
  * @return Builder
  */
 public function applyScopeToQuery($scope, $query)
 {
     if (is_string($scope)) {
         $scope = $this->getScope($scope);
     }
     if (!$scope->value) {
         return;
     }
     $value = is_array($scope->value) ? array_keys($scope->value) : $scope->value;
     /*
      * Condition
      */
     if ($scopeConditions = $scope->conditions) {
         if (is_array($value)) {
             $filtered = implode(',', array_build($value, function ($key, $_value) {
                 return [$key, Db::getPdo()->quote($_value)];
             }));
         } else {
             $filtered = Db::getPdo()->quote($value);
         }
         $query->whereRaw(strtr($scopeConditions, [':filtered' => $filtered]));
     }
     /*
      * Scope
      */
     if ($scopeMethod = $scope->scope) {
         $query->{$scopeMethod}($value);
     }
     return $query;
 }
開發者ID:janusnic,項目名稱:23copperleaf,代碼行數:36,代碼來源:Filter.php

示例4: applyScopeToQuery

 /**
  * Applies a filter scope constraints to a DB query.
  * @param  string $scope
  * @param  Builder $query
  * @return Builder
  */
 public function applyScopeToQuery($scope, $query)
 {
     if (is_string($scope)) {
         $scope = $this->getScope($scope);
     }
     if (!$scope->value) {
         return;
     }
     switch ($scope->type) {
         case 'date':
             if ($scope->value instanceof Carbon) {
                 $value = $scope->value;
                 /*
                  * Condition
                  */
                 if ($scopeConditions = $scope->conditions) {
                     $query->whereRaw(DbDongle::parse(strtr($scopeConditions, [':filtered' => $value->format('Y-m-d'), ':after' => $value->format('Y-m-d H:i:s'), ':before' => $value->copy()->addDay()->addMinutes(-1)->format('Y-m-d H:i:s')])));
                 } elseif ($scopeMethod = $scope->scope) {
                     $query->{$scopeMethod}($value);
                 }
             }
             break;
         case 'daterange':
             if (is_array($scope->value) && count($scope->value) > 1) {
                 list($after, $before) = array_values($scope->value);
                 if ($after && $after instanceof Carbon && $before && $before instanceof Carbon) {
                     /*
                      * Condition
                      */
                     if ($scopeConditions = $scope->conditions) {
                         $query->whereRaw(DbDongle::parse(strtr($scopeConditions, [':afterDate' => $after->format('Y-m-d'), ':after' => $after->format('Y-m-d H:i:s'), ':beforeDate' => $before->format('Y-m-d'), ':before' => $before->format('Y-m-d H:i:s')])));
                     } elseif ($scopeMethod = $scope->scope) {
                         $query->{$scopeMethod}($after, $before);
                     }
                 }
             }
             break;
         default:
             $value = is_array($scope->value) ? array_keys($scope->value) : $scope->value;
             /*
              * Condition
              */
             if ($scopeConditions = $scope->conditions) {
                 /*
                  * Switch scope: multiple conditions, value either 1 or 2
                  */
                 if (is_array($scopeConditions)) {
                     $conditionNum = is_array($value) ? 0 : $value - 1;
                     list($scopeConditions) = array_slice($scopeConditions, $conditionNum);
                 }
                 if (is_array($value)) {
                     $filtered = implode(',', array_build($value, function ($key, $_value) {
                         return [$key, Db::getPdo()->quote($_value)];
                     }));
                 } else {
                     $filtered = Db::getPdo()->quote($value);
                 }
                 $query->whereRaw(DbDongle::parse(strtr($scopeConditions, [':filtered' => $filtered])));
             } elseif ($scopeMethod = $scope->scope) {
                 $query->{$scopeMethod}($value);
             }
             break;
     }
     return $query;
 }
開發者ID:aaronleslie,項目名稱:aaronunix,代碼行數:71,代碼來源:Filter.php


注:本文中的Builder::whereRaw方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。