Untitled
unknown
php
2 years ago
2.0 kB
5
Indexable
<?php class Logs { private $logsTable = 'Logs'; public $id; public $Action; public $Result; public $Sync; private $conn; public function __construct($db){ $this->conn = $db; } public function listLogs(){ $sqlQuery = "SELECT * FROM ".$this->logsTable." "; if(!empty($_POST["search"]["value"])){ $sqlQuery .= 'where(id LIKE "%'.$_POST["search"]["value"].'%" '; $sqlQuery .= ' OR Action LIKE "%'.$_POST["search"]["value"].'%" '; $sqlQuery .= ' OR Result LIKE "%'.$_POST["search"]["value"].'%" '; } if(!empty($_POST["order"])){ $sqlQuery .= 'ORDER BY '.$_POST['order']['0']['column'].' '.$_POST['order']['0']['dir'].' '; } else { $sqlQuery .= 'ORDER BY id ASC '; } if($_POST["length"] != -1){ $sqlQuery .= 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length']; } $stmt = $this->conn->prepare($sqlQuery); $stmt->execute(); $result = $stmt->get_result(); $stmtTotal = $this->conn->prepare("SELECT * FROM ".$this->logsTable); $stmtTotal->execute(); $allResult = $stmtTotal->get_result(); $allRecords = $allResult->num_rows; $displayRecords = $result->num_rows; $records = array(); while ($record = $result->fetch_assoc()) { $record['errorlog'] == 0) $rows = array(); $rows[] = $record['id']; $rows[] = ucfirst($record['Action']); $rows[] = $record['Result']; $rows[] = $record['Sync']; $records[] = $rows; } $output = array( "draw" => intval($_POST["draw"]), "iTotalRecords" => $displayRecords, "iTotalDisplayRecords" => $allRecords, "data" => $records ); echo json_encode($output); } } ?>
Editor is loading...