-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.php
More file actions
48 lines (42 loc) · 1.23 KB
/
api.php
File metadata and controls
48 lines (42 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
session_start();
ob_start('ob_gzhandler');
$executionStartTime = microtime(true);
include 'Db.php';
$db = new Db();
$action = (isset($_POST['action']) ? $_POST['action'] : null);
// take action
$result = "error: action not found";
switch ($action) {
case 'createTables':
$result = $db->createTables();
break;
case 'insertWithTransaction':
$rowCount = (isset($_POST['rowCount']) ? $_POST['rowCount'] : null);
$result = $db->insertWithTransaction($rowCount);
break;
case 'insertNoTransaction':
$rowCount = (isset($_POST['rowCount']) ? $_POST['rowCount'] : null);
$result = $db->insertNoTransaction($rowCount);
break;
case 'tableInfo':
$result = $db->tableInfo();
break;
case 'version':
$result = $db->version();
break;
default:
//$result = $db->hello();
}
$executionEndTime = microtime(true);
$seconds = $executionEndTime - $executionStartTime;
$execTime = "Execution time= {$seconds} seconds.";
//error_log(PHP_EOL . $execTime);
$data = array(
"result" => $result,
"action" => $action,
"msg" => "no msg",
'executionTimeSeconds' => $seconds,
);
// all done return results to page
echo json_encode($data);