<?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 */
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")', ); }}
/* End of file userdatatable.php / /_ Location: ./application/models/user_datatable.php */