Eloquent::whereRaw PHP Method

whereRaw() public static method

Add a raw where clause to the query.
public static whereRaw ( string $sql, array $bindings = [], string $boolean = 'and' )
$sql string
$bindings array
$boolean string
        public static function whereRaw($sql, $bindings = array(), $boolean = 'and')
        {
            return \Illuminate\Database\Query\Builder::whereRaw($sql, $bindings, $boolean);
        }

Usage Example

コード例 #1
0
ファイル: Datatables.php プロジェクト: testoodoo/OoodooSiteUp
 /**
  * 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);
             }
         }
     }
 }
All Usage Examples Of Eloquent::whereRaw
Eloquent