Skip to content

Commit

Permalink
Merge pull request #1988 from royduin/patch-1
Browse files Browse the repository at this point in the history
[8.0] Keep select bindings option.
  • Loading branch information
yajra authored Feb 13, 2019
2 parents 8aedd88 + fad575b commit db2a58d
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/QueryDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ class QueryDataTable extends DataTableAbstract
*/
protected $skipTotalRecords = false;

/**
* Flag to keep the select bindings.
*
* @var bool
*/
protected $keepSelectBindings = false;

/**
* Can the DataTable engine be created with these parameters.
*
Expand Down Expand Up @@ -131,6 +138,18 @@ public function skipTotalRecords()
return $this;
}

/**
* Keep the select bindings.
*
* @return $this
*/
public function keepSelectBindings()
{
$this->keepSelectBindings = true;

return $this;
}

/**
* Count total items.
*
Expand Down Expand Up @@ -187,7 +206,9 @@ protected function prepareCountQuery()
if (! $this->isComplexQuery($builder)) {
$row_count = $this->wrap('row_count');
$builder->select($this->connection->raw("'1' as {$row_count}"));
$builder->setBindings([], 'select');
if (! $this->keepSelectBindings) {
$builder->setBindings([], 'select');
}
}

return $builder;
Expand Down

0 comments on commit db2a58d

Please sign in to comment.