datatable limit correction

This commit is contained in:
2023-10-17 17:27:24 +07:00
parent d7644da5a9
commit def07c4e6f
+10 -9
View File
@@ -240,14 +240,6 @@ final class Table {
$i_order = $this->__cpa->Get("order", 0);
if ($id_draw > 0) {
$t_order = "ASC";
if ($i_order <> 0) {
$t_order = ($i_order[0]['dir']=="asc") ? "ASC" : "DESC";
$i_order = $i_order[0]['column'];
}
$sql_limit = ($i_start>=0 && $i_length != -1) ? " LIMIT ".$i_start.", ".$i_length : "";
$sql_order = ($this->__afield[$i_order]) ? " ORDER BY ".$this->__afield[$i_order]." ".$t_order : "";
$record = 0;
$this->__cdb->Query("SELECT COUNT(*) Item FROM ".$this->__ttable.$this->__twhere);
if ($this->__cdb->Next()) $record = intval($this->__cdb->Row("Item", 0));
@@ -255,9 +247,18 @@ final class Table {
$adata['recordsTotal'] = $record;
$adata['recordsFiltered'] = $record;
$t_order = "ASC";
if ($i_order <> 0) {
$t_order = ($i_order[0]['dir']=="asc") ? "ASC" : "DESC";
$i_order = $i_order[0]['column'];
}
if ($i_length > $record) $i_length = -1;
$sql_limit = ($i_start>=0 && $i_length != -1) ? " LIMIT ".$i_start.", ".$i_length : "";
$sql_order = ($this->__afield[$i_order]) ? " ORDER BY ".$this->__afield[$i_order]." ".$t_order : "";
$adata['data'] = [];
$this->__cdb->Query("SELECT ".$this->__tfield." FROM ".$this->__ttable.$this->__twhere.$sql_order.$sql_limit);
$adata['sql'] = "SELECT ".$this->__tfield." FROM ".$this->__ttable.$this->__twhere.$sql_order.$sql_limit;
//$adata['sql'] = "SELECT ".$this->__tfield." FROM ".$this->__ttable.$this->__twhere.$sql_order.$sql_limit;
while ($this->__cdb->Next()) {
$abaris = [];
$aoption = ['button'=>[]];