本文整理汇总了PHP中Illuminate\Database\Query\Builder::getQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::getQuery方法的具体用法?PHP Builder::getQuery怎么用?PHP Builder::getQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Query\Builder
的用法示例。
在下文中一共展示了Builder::getQuery方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkQueryGroupBy
protected function checkQueryGroupBy()
{
$groups = $this->query->getQuery()->groups;
$keyGroup = $this->model->getQualifiedKeyName();
if (empty($groups) || !in_array($keyGroup, $groups)) {
$this->query->groupBy($keyGroup);
}
}
示例2: __construct
/**
* EloquentManager constructor.
*
* @param Builder|\Eloquent $model
* @param Request $request
*/
public function __construct($model, Request $request)
{
$this->response = new DataTable();
$this->query = $model instanceof Builder ? $model : $model->getQuery();
$this->request = $request;
// $this->columns = $this->query->columns;
$this->connection = $model->getConnection();
$this->prefix = $this->connection->getTablePrefix();
$this->database = $this->connection->getDriverName();
}
示例3: count
/**
* Counts current query
*
* @param string $count variable to store to 'count_all' for iTotalRecords, 'display_all' for iTotalDisplayRecords
*
* @return null
*/
protected function count($count = 'count_all')
{
//Get columns to temp var.
if ($this->query_type == 'eloquent') {
$query = $this->query->getQuery();
$connection = $this->query->getModel()->getConnection()->getName();
} else {
$query = $this->query;
$connection = $query->getConnection()->getName();
}
// if its a normal query ( no union ) replace the select with static text to improve performance
$countQuery = clone $query;
if (!preg_match('/UNION/i', $countQuery->toSql())) {
$countQuery->select(DB::raw("'1' as row"));
// if query has "having" clause add select columns
if ($countQuery->havings) {
foreach ($countQuery->havings as $having) {
if (isset($having['column'])) {
$countQuery->addSelect($having['column']);
} else {
// search filter_columns for query string to get column name from an array key
$found = false;
foreach ($this->filter_columns as $column => $filter) {
if ($filter['parameters'][0] == $having['sql']) {
$found = $column;
break;
}
}
// then correct it if it's an alias and add to columns
if ($found !== false) {
foreach ($this->columns as $col) {
$arr = preg_split('/ as /i', $col);
if (isset($arr[1]) && $arr[1] == $found) {
$found = $arr[0];
break;
}
}
$countQuery->addSelect($found);
}
}
}
}
}
// Clear the orders, since they are not relevant for count
$countQuery->orders = null;
$this->{$count} = DB::connection($connection)->table(DB::raw('(' . $countQuery->toSql() . ') AS count_row_table'))->setBindings($countQuery->getBindings())->count();
}
示例4: methodExists
/**
* Return whether the method
* exists on the query or not.
*
* @param $name
* @return bool
*/
protected function methodExists($name)
{
return method_exists($this->query->getQuery(), $name);
}
示例5: scopeSearchByFeature
/**
* Generic query used by scopes, but you can call it with custom feataure codes.
*
* @param \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder $query
* @param String $name
* @param String $feature_class The 1 character feature class
* @param array $featureCodes List of feature codes to use when returning results
* @return \Illuminate\Database\Query\Builder
*/
public function scopeSearchByFeature($query, $name = null, $feature_class = null, $featureCodes = null)
{
$table = 'geonames_geonames';
if (!isset($query->getQuery()->columns)) {
$query = $query->addSelect($this->usefulScopeColumns);
}
if ($name !== null) {
$query = $query->where($table . '.name', 'LIKE', $name);
}
$query = $query->where($table . '.feature_class', $feature_class)->whereIn($table . '.feature_code', $featureCodes);
return $query;
}
示例6: removeGroupBy
/**
* Remove the GROUP BY clause from a builder.
*
* @param Builder|QueryBuilder $builder
* @return Builder|QueryBuilder $builder with the groups property set to null.
*/
private function removeGroupBy($builder)
{
// Handle \Illuminate\Database\Eloquent\Builder
if ($builder instanceof Builder) {
$query = $builder->getQuery();
$query->groups = null;
$builder->setQuery($query);
} else {
$builder->groups = null;
}
return $builder;
}