File manager - Edit - /home/wwwroot/camplus.hk/master.camplus.hk/public_html/application/libraries/Datatable.php
Back
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Datatable { public function __construct($params = array()) { } public function __destruct() { } public function get($db,$post,$debug=false){ $where_array=[]; $or_where_array=[]; if(!empty($post['columns'])) { foreach ($post['columns'] as $key=> $column) { if ($column['data'] != '' || $column['name'] != '') { if ($column['search']['value'] != '') $where_array[$column['data'] . ' LIKE'] = $column['search']['value'] . '%'; if ($column['searchable']) $or_where_array[$column['data']] = $post['search']['value'] . '%'; } if ($key == $post['order'][0]['column']) { $order = $column['data']; } } } $len = $post['length']; if ($len != -1) { $db->limit($len, $post['start']); } if(count($or_where_array)>0) { $or_where_sql = []; foreach($or_where_array as $key=>$value) { if(!empty(trim($value)) || trim($value!='')) $or_where_sql[] = $key . ' LIKE "' .trim($value) .'"'; } $db->having('(' . implode(' OR ', $or_where_sql) .')'); } if (count($where_array) > 0) { $db->having($where_array); } if(is_array($post['order'][0]['dir'])) { $db->order_by($post['columns'][$post['order'][0]['dir'][0]]['data'], $post['order'][0]['dir'][1]); } else { $db->order_by($order, $post['order'][0]['dir']); } $data = $db->get()->result_array(); $last_query = $db->last_query(); $pos = strpos($last_query,'LIMIT'); if ($pos != FALSE) { $last_query = substr($last_query, 0, $pos); } $result = $db->query($last_query)->result_array(); $return["draw"]= $post['draw']; $return["recordsTotal"]= count($result); $return["recordsFiltered"] = count($result); $return["data"]=$data; if($debug) $return["query"]=$last_query; echo json_encode($return,JSON_UNESCAPED_UNICODE); } }
| ver. 1.4 |
Github
|
.
| PHP 7.2.34 | Generation time: 0.13 |
proxy
|
phpinfo
|
Settings