Skip to content
Open
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
20 changes: 18 additions & 2 deletions application/libraries/Datatables.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Datatables
private $ci;
private $table;
private $distinct;
private $count_column;
private $group_by = array();
private $select = array();
private $joins = array();
Expand Down Expand Up @@ -242,6 +243,18 @@ public function unset_column($column)
return $this;
}

/**
* Sets the column used for counting improving performance
*
* @param string $column
* @return mixed
*/
public function set_count_column($column)
{
$this->count_column = $column;
return $this;
}

/**
* Builds all the necessary query segments and performs the main query based on results set from chained statements
*
Expand Down Expand Up @@ -407,6 +420,9 @@ private function get_total_results($filtering = FALSE)
if($filtering)
$this->get_filtering();

if(strlen($this->count_column) > 0)
$this->ci->db->select($this->count_column);

foreach($this->joins as $val)
$this->ci->db->join($val[0], $val[1], $val[2]);

Expand Down Expand Up @@ -604,8 +620,8 @@ private function jsonify($result = FALSE)
return '{' . join(',', $json) . '}';
}
}
/**
/**
* returns the sql statement of the last query run
* @return type
*/
Expand Down