Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.0] Keep select bindings option. #1988

Merged
merged 2 commits into from
Feb 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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