JSlip
1.0
jslip
src
module
UserTax
UserTaxModel.php
Go to the documentation of this file.
1
<?php
8
require_once(dirname(__FILE__) .
'/../../lib/Model.php'
);
9
10
class
UserTaxModel
extends
Model
11
{
12
public
$bid
;
13
14
function
__construct
(
$bid
) {
15
$this->bid =
$bid
;
16
}
17
18
public
function
getList
() {
19
20
$this->
connect
();
21
22
$sql =
"SELECT * FROM `t_tax`"
23
.
" WHERE `bid` = "
. $this->
esc
($this->bid) .
" ORDER BY `rate` ASC"
;
24
$rec = $this->
getRecord
($sql);
25
26
$this->
close
();
27
28
return
$rec;
29
}
30
31
public
function
chkDup
($name) {
32
33
$this->
connect
();
34
$sql =
"SELECT COUNT(*) AS `cnt` FROM `t_tax`"
35
.
" WHERE `bid` = "
. $this->
esc
($this->bid) .
" AND `name` = '"
. $this->
esc
($name) .
"'"
;
36
$rec = $this->
getRecord
($sql);
37
$this->
close
();
38
39
return
$rec[0][
'cnt'
];
40
}
41
42
public
function
regist
($param) {
43
44
$err =
''
;
45
46
$this->
connect
();
47
$this->
begin
();
48
49
try
{
50
51
$sql =
"UPDATE `t_tax` SET"
52
.
" `bid`"
.
" = '"
. $this->
esc
($this->bid) .
"'"
53
.
", `name`"
.
" = '"
. $this->
esc
($param[
'name'
]) .
"'"
54
.
", `rate`"
.
" = '"
. $this->
esc
($param[
'rate'
]) .
"'"
55
.
", `valid_flg`"
.
" = "
. $this->
esc
($param[
'valid_flg'
])
56
.
" WHERE `id` = '"
. $this->
esc
($param[
'id'
]) .
"'"
57
;
58
$ans = $this->
query
($sql);
59
60
}
catch
(Exception $e) {
61
$err = $e->getMessage();
62
}
63
64
if
(empty($err)) {
65
$this->
commit
();
66
}
else
{
67
$this->
rollback
();
68
}
69
70
$this->
close
();
71
72
return
$err;
73
}
74
75
public
function
insert
($param) {
76
77
$err =
''
;
78
79
$this->
connect
();
80
$this->
begin
();
81
82
try
{
83
84
$sql =
"INSERT INTO `t_tax`"
85
.
" (`bid`, `name`, `rate`, `valid_flg`)"
86
.
" VALUES"
87
.
" ('"
. $this->
esc
($this->bid) .
"'"
88
.
", '"
. $this->
esc
($param[
'name'
]) .
"'"
89
.
", '"
. $this->
esc
($param[
'rate'
]) .
"'"
90
.
", "
. $this->
esc
($param[
'valid_flg'
])
91
.
")"
92
;
93
$ans = $this->
query
($sql);
94
95
}
catch
(Exception $e) {
96
$err = $e->getMessage();
97
}
98
99
if
(empty($err)) {
100
$this->
commit
();
101
}
else
{
102
$this->
rollback
();
103
}
104
105
$this->
close
();
106
107
return
$err;
108
}
109
110
public
function
delete
($param) {
111
112
$err =
''
;
113
$id = $param[
'id'
];
114
115
$this->
connect
();
116
$this->
begin
();
117
118
try
{
119
120
$sql =
"DELETE FROM `t_tax` WHERE `id` = '"
. $this->
esc
($id) .
"'"
;
121
$ans = $this->
query
($sql);
122
123
}
catch
(Exception $e) {
124
$err = $e->getMessage();
125
}
126
127
if
(empty($err)) {
128
$this->
commit
();
129
}
else
{
130
$this->
rollback
();
131
}
132
133
$this->
close
();
134
135
return
$err;
136
}
137
138
public
function
getData
($id) {
139
140
$this->
connect
();
141
$sql =
"SELECT * FROM `t_tax` WHERE `id` = '"
. $this->
esc
($id) .
"'"
;
142
$rec = $this->
getRecord
($sql);
143
$this->
close
();
144
145
return
(empty($rec[0])) ? [] : $rec[0];
146
}
147
148
public
function
setValidFlg
($param) {
149
150
$err =
''
;
151
152
$this->
connect
();
153
$this->
begin
();
154
155
try
{
156
157
$sql =
"UPDATE `t_tax` SET"
158
.
" `valid_flg` = "
. $param[
'valid_flg'
]
159
.
" WHERE `id` = '"
. $this->
esc
($param[
'id'
]) .
"'"
160
;
161
$ans = $this->
query
($sql);
162
163
}
catch
(Exception $e) {
164
$err = $e->getMessage();
165
}
166
167
if
(empty($err)) {
168
$this->
commit
();
169
}
else
{
170
$this->
rollback
();
171
}
172
173
$this->
close
();
174
175
return
$err;
176
}
177
}
UserTaxModel
Definition:
UserTaxModel.php:10
Model\connect
connect()
Definition:
Model.php:12
Model\begin
begin()
Definition:
Model.php:31
Model\query
query($sql)
Definition:
Model.php:47
UserTaxModel\$bid
$bid
Definition:
UserTaxModel.php:12
Model\getRecord
getRecord($sql)
Definition:
Model.php:55
UserTaxModel\chkDup
chkDup($name)
Definition:
UserTaxModel.php:31
UserTaxModel\__construct
__construct($bid)
Definition:
UserTaxModel.php:14
UserTaxModel\regist
regist($param)
Definition:
UserTaxModel.php:42
UserTaxModel\getList
getList()
Definition:
UserTaxModel.php:18
Model
Definition:
Model.php:8
Model\commit
commit()
Definition:
Model.php:35
UserTaxModel\insert
insert($param)
Definition:
UserTaxModel.php:75
Model\close
close()
Definition:
Model.php:27
Model\esc
esc($str)
Definition:
Model.php:43
UserTaxModel\setValidFlg
setValidFlg($param)
Definition:
UserTaxModel.php:148
UserTaxModel\getData
getData($id)
Definition:
UserTaxModel.php:138
Model\rollback
rollback()
Definition:
Model.php:39
Generated by
1.8.16