source: trunk/FACT++/www/schedule/load.php

Last change on this file was 20052, checked in by tbretz, 4 years ago
Updated mysql calls.
File size: 2.0 KB
Line 
1<?php
2
3
4if (!isset($_POST['n']))
5 return header('HTTP/1.0 400 Syntax error.');
6
7// ================================================================
8// Database interaction
9// ================================================================
10
11function query($sql, $query)
12{
13 $sql = $sql->query($query);
14 if (!$sql)
15 die($sql->error);
16
17 $rows = array();
18 while($row = $sql->fetch_assoc())
19 $rows[] = $row;
20
21 print(json_encode($rows).'\n');
22}
23
24// ----------------------------------------------------------------
25
26$cut = "";
27if (isset($_POST['t']))
28{
29 $cut = $_POST['n'].' '.$_POST['t'];
30
31 $d = new DateTime($cut);
32 if ($d->format("His")<120000)
33 {
34 $d->add(new DateInterval('P1D')); // PnYnMnDTnHnMnS
35 $cut = $d->format("Y-m-d H:i:s");
36 }
37
38 $cut = " AND fStart>'".$cut."' ";
39}
40
41// ----------------------------------------------------------------
42
43require_once 'config.php';
44
45$sql = new mysqli($dbhost, $dbuser, $dbpass);
46
47if ($sql->connect_error)
48 die($sql->connect_error);
49
50if (!$sql->select_db($dbname))
51 die($sql->error);
52
53/*mixed date_sunrise ( int $timestamp [, int $format = SUNFUNCS_RET_STRING [, float $latitude = ini_get("date.default_latitude") [, float $longitude = ini_get("date.default_longitude") [, float $zenith = ini_get("date.sunrise_zenith") [, float $gmt_offset = 0 ]]]]] )*/
54
55query($sql, "SELECT DISTINCT(DATE(ADDTIME(fStart, '-12:00'))) AS 'd' FROM Schedule");
56query($sql, "SELECT fSourceKEY AS 'key', fSourceName AS 'val' FROM Source WHERE fSourceTypeKEY=1");
57query($sql, "SELECT fMeasurementTypeKEY AS 'key', fMeasurementTypeName AS 'val' FROM MeasurementType");
58query($sql, "SELECT * FROM Schedule WHERE DATE(ADDTIME(fStart, '-12:00:00')) = '".$_POST['n']."'".$cut."ORDER BY fStart ASC, fMeasurementID ASC");
59
60//sleep(3);
61
62//print($test1."|".$test2."|".$test3."|SELECT * FROM Schedule WHERE DATE(ADDTIME(fStart, '-12:00:00')) = '".$_POST['day']."'".$cut."ORDER BY fScheduleID ASC, fMeasurementID ASC\n");
63
64?>
Note: See TracBrowser for help on using the repository browser.