本文整理汇总了PHP中Builder::getQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::getQuery方法的具体用法?PHP Builder::getQuery怎么用?PHP Builder::getQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Builder
的用法示例。
在下文中一共展示了Builder::getQuery方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: databasePrefix
/**
* Returns current database prefix
*
* @return string
*/
public function databasePrefix()
{
if ($this->query_type == 'builder') {
$query = $this->query;
} else {
$query = $this->query->getQuery();
}
return $query->getGrammar()->getTablePrefix();
}
示例2: dateFormatDb
/**
* Date Formate Database
*
* @param Builder $query Builder
* @param string $key Column
* @param string $operator String Operator
*
* @return string
*/
private function dateFormatDb($query, $key, $operator)
{
if (!$this->grammar) {
$this->grammar = $query->getQuery()->getGrammar();
}
$key = $this->grammar->wrap($key);
$formatDb = sprintf("%s %s ?", $key, $operator);
switch (true) {
case $this->grammar instanceof \Illuminate\Database\Query\Grammars\MySqlGrammar:
$formatDb = sprintf("DATE(%s) %s ?", $key, $operator);
break;
case $this->grammar instanceof \Illuminate\Database\Query\Grammars\PostgresGrammar:
$formatDb = sprintf("DATE_TRUNC('day', %s) %s ?", $key, $operator);
break;
case $this->grammar instanceof \Illuminate\Database\Query\Grammars\SQLiteGrammar:
$formatDb = sprintf("strftime('%%Y-%%m-%%d', %s) %s ?", $key, $operator);
break;
case $this->grammar instanceof \Illuminate\Database\Query\Grammars\SqlServerGrammar:
$formatDb = sprintf("CAST(%s AS DATE) %s ?", $key, $operator);
}
return $formatDb;
}
示例3: addForceDelete
/**
* Add the force delete extension to the builder.
*
* @param \Illuminate\Database\Eloquent\Builder $builder
* @return void
*/
protected function addForceDelete(Builder $builder)
{
$builder->macro('forceDelete', function (Builder $builder) {
return $builder->getQuery()->delete();
});
}
示例4: remove
/**
* Remove the scope from the given Eloquent query builder.
*
* @param \Illuminate\Database\Eloquent\Builder $builder
* @param \Illuminate\Database\Eloquent\Model $model
* @return void
*/
public function remove(Builder $builder, Model $model)
{
$column = $model->getQualifiedDeletedAtColumn();
$query = $builder->getQuery();
$query->wheres = collect($query->wheres)->reject(function ($where) use($column) {
return $this->isSoftDeleteConstraint($where, $column);
})->values()->all();
}