-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_case.php
More file actions
153 lines (108 loc) · 3.67 KB
/
test_case.php
File metadata and controls
153 lines (108 loc) · 3.67 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
include 'config.php';
include 'autoload.php';
class TestCase {
protected $postman;
public function __construct($host, $userid, $password, $database) {
$this->postman = Postman::getInstance( $host, $userid, $password, $database, false );
}
public function createByLoop() {
$query = "INSERT INTO `transaction_np` ";
$query .= "( `trans_time`, `price`, `created_date_time`, `is_del` ) ";
$query .= "VALUES ";
$query .= "( ?, ?, ?, ? )";
$list_params = array();
for( $i = 0; $i < 5; $i++) {
$trans_time[$i] = date('Y-m-d H:i:s');
$price[$i] = rand(14,51000);
$created_date_time[$i] = date('Y-m-d H:i:s');
$is_det[$i] = 0;
$fmt = 'sdsi';
$params = array($fmt);
$params[] = &$trans_time[$i];
$params[] = &$price[$i];
$params[] = &$created_date_time[$i];
$params[] = &$is_det[$i];
array_push($list_params, $params);
}
$idx = $this->postman->execute($query, $list_params, true);
var_dump($idx);
}
public function createByPush() {
$query = "INSERT INTO `transaction_np` ";
$query .= "( `trans_time`, `price`, `created_date_time`, `is_del` ) ";
$query .= "VALUES ";
$query .= "( ?, ?, ?, ? )";
$fmt = 'sdsi';
$list_params = array();
///////////////////////////////////////////////////
$trans_time = '2017-09-12 11:22:33';
$price = 50;
$created_date_ = '2017-09-13 11:22:33';
$is_det = 0;
$params = array($fmt);
$params[] = &$trans_time;
$params[] = &$price;
$params[] = &$created_date_;
$params[] = &$is_det;
array_push($list_params, $params);
///////////////////////////////////////////////////
$trans_time = '2017-09-12 11:22:33';
$price = 50;
$created_date_ = '2017-09-13 11:22:33';
$is_det = 0;
array_push($list_params, array($fmt, &$trans_time, &$price, &$created_date_, &$is_det));
///////////////////////////////////////////////////
$idx = $this->postman->execute($query, $list_params, true);
var_dump($idx);
}
public function getList() {
$query = "SELECT ";
$query .= "* ";
$query .= "FROM ";
$query .= "`transaction_np` ";
$query .= "WHERE ";
$query .= "`is_del`=? ";
$query .= "ORDER BY idx desc ";
$query .= "limit ? offset ? ";
$fmt = 'iii';
$status = 0;
$limit = 2;
$offset = 0;
$list = array($fmt, &$status, &$limit, &$offset);
$idx = $this->postman->executeList($query, $list);
var_dump($idx);
}
public function getTotal() {
$query = "SELECT ";
$query .= "COUNT(*) as cnt ";
$query .= "FROM ";
$query .= "`transaction_np` ";
$query .= "WHERE ";
$query .= "`is_del`=? ";
$fmt = 'i';
$status = 0;
$list = array($fmt, &$status);
$idx = $this->postman->executeList($query, $list);
var_dump($idx);
}
public function get() {
$query = "SELECT ";
$query .= "* ";
$query .= "FROM ";
$query .= "`transaction_np` ";
$query .= "WHERE ";
$query .= "`idx`=? ";
$fmt = 'i';
$idx = 1;
$list = array($fmt, &$idx);
$idx = $this->postman->executeObject($query, $list);
var_dump($idx);
}
}
$tc = new TestCase($host, $userid, $password, $database);
$tc->createByLoop();
$tc->createByPush();
$tc->getList();
$tc->getTotal();
$tc->get();