zepernick / Codeigniter-DataTables

CodeIgniter Library For Ajax Server Side DataTables 1.10 >
MIT License
94 stars 95 forks source link

Enable support for HAVING clauses / Expand data format options to native function and class methods #23

Closed syosoft closed 8 years ago

syosoft commented 8 years ago

Example usage:

<?php defined('BASEPATH') OR die('No direct script access allowed');

class User_datatable implements DatatableModel { /* * @ return * Expressions / Columns to append to the select created by the Datatable library. * Associative array where the key is the sql alias and the value is the sql expression / public function appendToSelectStr() { return array( 'full_name' => '(select meta.value from meta where meta.model = "user" and meta.model_id = user.user_id and meta.key = "full_name")', 'last_login_date' => '(select meta.value from meta where meta.model = "user" and meta.model_id = user.user_id and meta.key = "last_login_date")', ); }

/**
 * @return
 *      String table name to select from
 */
public function fromTableStr() {
    return 'user';
}

/**
 * @return
 *     Associative array of joins.  Return NULL or empty array  when not joining
 */
public function joinArray() {
    return NULL;
}

/**
 *
 * @return
 *    Static where clause to be appended to all search queries.  Return NULL or empty array
 * when not filtering by additional criteria
 */
public function whereClauseArray() {
    return array('user.deleted_date' => NULL);
}

}

/* End of file userdatatable.php / /_ Location: ./application/models/user_datatable.php */

syosoft commented 8 years ago

Didn't work at all as I had hoped. Clashing between where and having clauses.