-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccountInfo.php
More file actions
83 lines (65 loc) · 1.73 KB
/
accountInfo.php
File metadata and controls
83 lines (65 loc) · 1.73 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
session_start();
ob_start('ob_gzhandler');
$executionStartTime = microtime(true);
include 'AccountInfoDb.php';
$db = new AccountInfoDb();
$action = (isset($_POST['action']) ? $_POST['action'] : null);
// uncomment to create the tables
//$action = 'create';
// take action
$result = "error: action not found";
switch ($action) {
case 'create':
$result = $db->createTables();
break;
case 'save':
$result = $db->createTables();
// get post data here
$data = json_decode((isset($_POST['accountInfo']) ? $_POST['accountInfo'] : null));
$result = save($data);
break;
case 'load':
$result = $db->createTables();
// get post data here
$data = json_decode((isset($_POST['accountInfo']) ? $_POST['accountInfo'] : null));
$result = load($data);
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);
function save($data)
{
global $db;
// $data = new StdClass();
// $data->key = $query->key;
// $data->value = $query->value;
$result = $db->checkKey($data);
if ($result != '0') {
$result = $db->update($data);
} else {
$result = $db->save($data);
}
return $result;
}
function load($query)
{
global $db;
$data = new StdClass();
$data->key = $query->key;
$result = $db->load($data);
// if ok
return $result;
}