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

A small wish #8

Closed
andrejflorjancic opened this issue Dec 16, 2016 · 2 comments
Closed

A small wish #8

andrejflorjancic opened this issue Dec 16, 2016 · 2 comments

Comments

@andrejflorjancic
Copy link
Contributor

andrejflorjancic commented Dec 16, 2016

Can you change all private functions to protected. A have written "class MySqlDatatables extends Datatables" that optimizes count of result rows. In this class I override methods query and execute.

class MySqlDatatables extends Datatables {

public function query($query)
{
    $this->columns = $this->setcolumns($query);
    $columns = implode(", ", $this->columns);
    $query = rtrim($query, "; ");
    $this->sql = "Select SQL_CALC_FOUND_ROWS $columns from ($query)t";

    return $this;
}

protected function execute()
{
    $this->recordstotal = $this->db->count($this->sql); // unfiltered data count is here.
    $where = $this->filter();

    $this->data = $this->db->query($this->sql . $where . $this->orderby() . $this->limit());
    $rowCounts = $this->db->query("SELECT FOUND_ROWS() as rowCount");  // filtered data count is here.
    $this->recordsfiltered = $rowCounts[0]['rowCount'];

    $this->query = $this->sql . $where . $this->orderby() . $this->limit();

    return $this;
}

}

@n1crack
Copy link
Owner

n1crack commented Dec 17, 2016

done :)

@n1crack n1crack closed this as completed Dec 17, 2016
@andrejflorjancic
Copy link
Contributor Author

thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants