本文整理匯總了PHP中Eloquent::whereRaw方法的典型用法代碼示例。如果您正苦於以下問題:PHP Eloquent::whereRaw方法的具體用法?PHP Eloquent::whereRaw怎麽用?PHP Eloquent::whereRaw使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Eloquent
的用法示例。
在下文中一共展示了Eloquent::whereRaw方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
}
}
}
示例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);
}
}
}
}