12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- include 'con.php';
- //error handling
- ini_set('display_errors', 1);
- error_reporting(E_ALL);
- //variables from centurio
- $toolList = $_POST['toolList'];
- $toolList = json_decode($toolList);
- $dtc = [];
- $articles = [];
- //db
- foreach ($toolList as $toolID){
- $sql = "SELECT * FROM (SELECT * FROM DTC_TOOL_LC_EVENT WHERE TOOL_ID = '{$toolID}' ORDER BY DATE_TIME DESC) WHERE ROWNUM <= 5";
- $res = sqlStm($sql);
- $article = $res["ARTICLE_ID"];
- if (!array_filter($article)) {
- $newsql = "SELECT * FROM (SELECT * FROM DTC_TOOL_LC_EVENT WHERE TOOL_ID = '{$toolID}' AND ARTICLE_ID IS NOT NULL ORDER BY DATE_TIME DESC ) WHERE ROWNUM <= 1";
- $res2 = sqlStm($newsql);
- $lastArticle = $res2["ARTICLE_ID"][0];
- } else {
- $last = array_filter($article);
- $lastArticle = end($last);
- }
- //print_r($res);
- $dtc[$toolID] = $res;
- $articles[$toolID] = $lastArticle;
- }
- //print_r($dtc);
- //echo "---------------------------------------------------";
- //print_r($articles);
- //to centurio
- header('Content-Type:application/json');
- echo json_encode( array("lastArticles" => $articles, "dtc" => $dtc));
- ?>
|