JSlip
1.0
jslip
src
module
UserEra
UserEraModel.php
Go to the documentation of this file.
1
<?php
8
require_once(dirname(__FILE__) .
'/../../lib/Model.php'
);
9
10
class
UserEraModel
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_era`"
23
.
" WHERE `bid` = "
. $this->
esc
($this->bid) .
" ORDER BY `ymd` ASC"
;
24
$rec = $this->
getRecord
($sql);
25
26
$this->
close
();
27
28
return
$rec;
29
}
30
31
public
function
regist
($param) {
32
33
$err =
''
;
34
35
$this->
connect
();
36
$this->
begin
();
37
38
try
{
39
40
$sql =
"UPDATE `t_era` SET"
41
.
" `bid`"
.
" = '"
. $this->
esc
($this->bid) .
"'"
42
.
", `ymd`"
.
" = '"
. $this->
esc
($param[
'ymd'
]) .
"'"
43
.
", `era`"
.
" = '"
. $this->
esc
($param[
'era'
]) .
"'"
44
.
", `abr`"
.
" = '"
. $this->
esc
($param[
'abr'
]) .
"'"
45
.
" WHERE `id` = '"
. $this->
esc
($param[
'id'
]) .
"'"
46
;
47
$ans = $this->
query
($sql);
48
49
}
catch
(Exception $e) {
50
$err = $e->getMessage();
51
}
52
53
if
(empty($err)) {
54
$this->
commit
();
55
}
else
{
56
$this->
rollback
();
57
}
58
59
$this->
close
();
60
61
return
$err;
62
}
63
64
public
function
insert
($param) {
65
66
$err =
''
;
67
68
$this->
connect
();
69
$this->
begin
();
70
71
try
{
72
73
$sql =
"INSERT INTO `t_era`"
74
.
" (`bid`, `ymd`, `era`, `abr`, `delete_flg`)"
75
.
" VALUES"
76
.
" ('"
. $this->
esc
($this->bid) .
"'"
77
.
", '"
. $this->
esc
($param[
'ymd'
]) .
"'"
78
.
", '"
. $this->
esc
($param[
'era'
]) .
"'"
79
.
", '"
. $this->
esc
($param[
'abr'
]) .
"'"
80
.
", TRUE"
81
.
")"
82
;
83
$ans = $this->
query
($sql);
84
85
}
catch
(Exception $e) {
86
$err = $e->getMessage();
87
}
88
89
if
(empty($err)) {
90
$this->
commit
();
91
}
else
{
92
$this->
rollback
();
93
}
94
95
$this->
close
();
96
97
return
$err;
98
}
99
100
public
function
delete
($param) {
101
102
$err =
''
;
103
$id = $param[
'id'
];
104
105
$this->
connect
();
106
$this->
begin
();
107
108
try
{
109
110
$sql =
"DELETE FROM `t_era` WHERE `id` = '"
. $this->
esc
($id) .
"'"
;
111
$ans = $this->
query
($sql);
112
113
}
catch
(Exception $e) {
114
$err = $e->getMessage();
115
}
116
117
if
(empty($err)) {
118
$this->
commit
();
119
}
else
{
120
$this->
rollback
();
121
}
122
123
$this->
close
();
124
125
return
$err;
126
}
127
128
public
function
getData
($id) {
129
130
$this->
connect
();
131
$sql =
"SELECT * FROM `t_era` WHERE `id` = '"
. $this->
esc
($id) .
"'"
;
132
$rec = $this->
getRecord
($sql);
133
$this->
close
();
134
135
return
(empty($rec[0])) ? [] : $rec[0];
136
}
137
}
UserEraModel\insert
insert($param)
Definition:
UserEraModel.php:64
UserEraModel\getData
getData($id)
Definition:
UserEraModel.php:128
Model\connect
connect()
Definition:
Model.php:12
Model\begin
begin()
Definition:
Model.php:31
UserEraModel
Definition:
UserEraModel.php:10
Model\query
query($sql)
Definition:
Model.php:47
Model\getRecord
getRecord($sql)
Definition:
Model.php:55
UserEraModel\regist
regist($param)
Definition:
UserEraModel.php:31
Model
Definition:
Model.php:8
Model\commit
commit()
Definition:
Model.php:35
UserEraModel\getList
getList()
Definition:
UserEraModel.php:18
UserEraModel\__construct
__construct($bid)
Definition:
UserEraModel.php:14
Model\close
close()
Definition:
Model.php:27
Model\esc
esc($str)
Definition:
Model.php:43
UserEraModel\$bid
$bid
Definition:
UserEraModel.php:12
Model\rollback
rollback()
Definition:
Model.php:39
Generated by
1.8.16