android client
[scannr.git] / calls.json.php
blob:a/calls.json.php -> blob:b/calls.json.php
--- a/calls.json.php
+++ b/calls.json.php
@@ -8,7 +8,7 @@
             group by tgid, date_trunc(\'hour\', call_timestamp) order by time');
 
     $sth->execute(Array($timeFrom, $timeTo));
-    return $sth->fetchAll();
+    return $sth->fetchAll(PDO::FETCH_ASSOC);
 
 
 }
@@ -20,7 +20,7 @@
             group by sensor_id, date_trunc(\'day\', time) order by time');
 
     $sth->execute(Array($TGID));
-    return $sth->fetchAll();
+    return $sth->fetchAll(PDO::FETCH_ASSOC);
 }
 function getTGIDDataYears($TGID, $timeFrom, $timeTo)
 {
@@ -28,7 +28,7 @@
     $sth = $conn->prepare("select distinct extract('year' from call_timestamp) as year from recordings where tgid = ? order by year");
 
     $sth->execute(Array($TGID));
-    return $sth->fetchAll();
+    return $sth->fetchAll(PDO::FETCH_ASSOC);
 }
 
 function getTGIDDataMonths($TGID, $timeFrom, $timeTo)
@@ -37,7 +37,7 @@
     $sth = $conn->prepare("select distinct extract('month' from call_timestamp) as month, extract('year' from call_timestamp) as year from recordings where tgid = ?  order by year, month");
 
     $sth->execute(Array($TGID));
-    return $sth->fetchAll();
+    return $sth->fetchAll(PDO::FETCH_ASSOC);
 }
 
 function getTGIDDataDays($TGID, $timeFrom, $timeTo)
@@ -47,13 +47,21 @@
 
 
     $sth->execute(Array($TGID));
-    return $sth->fetchAll();
+    return $sth->fetchAll(PDO::FETCH_ASSOC);
 }
 $action = (isset($_REQUEST['action']) ? $_REQUEST['action'] : '');
 $TGID = (isset($_REQUEST['tgid']) ? $_REQUEST['tgid'] : '');
 $timefrom = (isset($_REQUEST['from']) ? $_REQUEST['from'] : '');
 $timeto = (isset($_REQUEST['to']) ? $_REQUEST['to'] : '');
 
+if ($action == "data") {
+$sth = $conn->prepare('select * from recordings
+            order by call_timestamp desc limit 100');
+
+$sth->execute(Array());
+
+echo json_encode ($sth->fetchAll(PDO::FETCH_ASSOC));
+}
 if ($action == "data_description") {
     $timefrom = strtotime($timefrom);
     $timeto = strtotime($timeto);