本文整理汇总了PHP中Illuminate\Database\Query\Builder::selectRaw方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::selectRaw方法的具体用法?PHP Builder::selectRaw怎么用?PHP Builder::selectRaw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Query\Builder
的用法示例。
在下文中一共展示了Builder::selectRaw方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getQuery
private function getQuery()
{
$concat = [];
foreach ($this->by as $id) {
$concat[] = "ifnull(`{$id}`,'')";
}
$key = "concat(" . implode(",'-',", $concat) . ") as `__key`";
$columns = implode(",", array_merge([$key], $this->sync));
return $this->builder->selectRaw($columns);
}
示例2: searchSelect
/**
* Apply relevance select on the subquery.
*
* @param \Sofa\Searchable\Subquery $subquery
* @param \Sofa\Searchable\ColumnCollection $columns
* @param array $words
* @return array
*/
protected function searchSelect(array $columns, array $words)
{
$cases = $bindings = [];
foreach ($columns as $column) {
list($cases[], $binding) = $this->buildCase($column, $words);
$bindings = array_merge_recursive($bindings, $binding);
}
$select = implode(' + ', $cases);
$this->query->selectRaw("max({$select}) as relevance", $bindings['select']);
return $bindings['where'];
}
示例3: selectRaw
/**
* Add a new "raw" select expression to the query.
*
* @param string $expression
* @param array $bindings
* @return \Illuminate\Database\Query\Builder|static
* @static
*/
public static function selectRaw($expression, $bindings = array())
{
return \Illuminate\Database\Query\Builder::selectRaw($expression, $bindings);
}
示例4: selectRaw
/**
* Add a new "raw" select expression to the query.
*
* @param string $expression
* @return \Illuminate\Database\Query\Builder|static
* @static
*/
public static function selectRaw($expression)
{
return \Illuminate\Database\Query\Builder::selectRaw($expression);
}
示例5: scopeUsed
/**
* Get tags that have been used more than 3 times and
* include that count with the tag.
*
* @param \Illuminate\Database\Query\Builder $query
* @return \Illuminate\Database\Query\Builder
*/
public function scopeUsed($query)
{
return $query->selectRaw('tags.*, COUNT(id) AS count')->join('post_tag', 'post_tag.tag_id', '=', 'tags.id')->groupBy('slug');
}
示例6: applyQuery
/**
* @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query
* @return void
*/
public function applyQuery($query)
{
$query->selectRaw($this->getSQLSelect($query->from) . ' as __interval__');
$query->groupBy('__interval__');
}
示例7: addRoleInheritCondition
/**
* Add the role inheritence "where" clause to the given query.
*
* @param \Illuminate\Database\Query\Builder $query
* @param \Illuminate\Database\Eloquent\Model $authority
* @param string $roles
* @return \Closure
*/
protected function addRoleInheritCondition(Builder $query, Model $authority, $roles)
{
$query->orWhere('level', '<', function ($query) use($authority, $roles) {
$query->selectRaw('max(level)')->from($roles)->whereExists($this->getAuthorityRoleConstraint($authority));
});
}