/**
  * Perform the SQL queries needed for an server-side processing requested,
  * utilising the helper functions of this class, limit(), order() and
  * filter() among others. The returned array is ready to be encoded as JSON
  * in response to an SSP request, or can be modified if needed before
  * sending back to the client.
  *
  *  @param  array $request Data sent to server by DataTables
  *  @param  array $sql_details SQL connection details - see sql_connect()
  *  @param  string $table SQL table to query
  *  @param  string $primaryKey Primary key of the table
  *  @param  array $columns Column information array
  *  @return array          Server-side processing response array
  */
 static function simple($request, $table, $primaryKey, $columns, $join = array(), $custom_where = array())
 {
     $bindings = array();
     $model = SSP::get_model();
     $fields = SSP::pluck_db($columns);
     $model->db->select("SQL_CALC_FOUND_ROWS " . $primaryKey, FALSE);
     $model->db->select($fields, FALSE);
     $model->db->from($table);
     foreach ($join as $j) {
         $model->db->join($j[0], $j[1]);
     }
     $where = SSP::filter($request, $columns, $bindings);
     if ($where != "") {
         $model->db->where($where);
     }
     if ($custom_where != "") {
         $model->db->where($custom_where);
     }
     foreach (SSP::order($request, $columns) as $order) {
         $order = explode("||", $order);
         $model->db->order_by($order[0], $order[1]);
     }
     $rows = isset($request['start']) ? $request['start'] : "";
     $limit = isset($request['length']) ? $request['length'] : 0;
     $model->db->limit($limit, $rows);
     $query = $model->db->get();
     $cquery = $model->db->query('SELECT FOUND_ROWS() AS `Count`');
     $recordsFiltered = $cquery->row()->Count;
     $data = $query->result_array();
     //print_r($data);exit;
     $query->free_result();
     $model->db->select($primaryKey);
     $model->db->from($table);
     $query = $model->db->get();
     //print_r($query);exit;
     $recordsTotal = $query->num_rows();
     $query->free_result();
     return array("draw" => intval($request['draw']), "recordsTotal" => intval($recordsTotal), "recordsFiltered" => intval($recordsFiltered), "data" => SSP::data_output($columns, $data));
 }