Repository navigation
Expand file tree
/
Copy pathPassportPasswordPreSessionTable.php
More file actions
102 lines (94 loc) · 3.38 KB
/
Copy pathPassportPasswordPreSessionTable.php
File metadata and controls
102 lines (94 loc) · 3.38 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
<?php
/**
* Created by PhpStorm.
* User: zhangjun
* Date: 23/08/2018
* Time: 6:12 PM
*/
class PassportPasswordPreSessionTable extends BaseTable
{
private $table = "passportPasswordPreSession";
private $columns = [
"id",
"userId",
"preSessionId",
"sitePubkPem"
];
private $selectColumns;
public function init()
{
$this->selectColumns = implode(",", $this->columns);
}
public function insertPreSessionData($info)
{
return $this->insertData($this->table, $info, $this->columns);
}
public function updatePreSessionData($where, $data)
{
return $this->updateInfo($this->table, $where, $data, $this->columns);
}
public function getInfoByPreSessionId($preSessionId)
{
$tag = __CLASS__ . "-" . __FILE__;
$startTime = microtime(true);
try {
$sql = "select
passportPassword.userId,
passportPassword.loginName,
passportPassword.nickname,
passportPassword.invitationCode,
passportPasswordPreSession.sitePubkPem
from
passportPassword
inner join
passportPasswordPreSession
on
passportPassword.userId = passportPasswordPreSession.userId
where
passportPasswordPreSession.preSessionId = :preSessionId";
$prepare = $this->db->prepare($sql);
$this->handlePrepareError($tag, $prepare);
$prepare->bindValue(":preSessionId", $preSessionId);
$prepare->execute();
$user = $prepare->fetch(\PDO::FETCH_ASSOC);
$this->ctx->Wpf_Logger->writeSqlLog($tag, $sql, $preSessionId, $startTime);
return $user;
} catch (Exception $ex) {
$this->ctx->Wpf_Logger->error($tag, "error_msg=" . $ex->getMessage());
return false;
}
}
public function delInfoByPreSessionId($preSessionId)
{
$tag = __CLASS__ . "-" . __FILE__;
$startTime = microtime(true);
try {
$sql = "delete from $this->table where preSessionId=:preSessionId";
$prepare = $this->db->prepare($sql);
$this->handlePrepareError($tag, $prepare);
$prepare->bindValue(":preSessionId", $preSessionId);
$prepare->execute();
$this->ctx->Wpf_Logger->writeSqlLog($tag, $sql, $preSessionId, $startTime);
} catch (Exception $ex) {
$this->ctx->Wpf_Logger->error($tag, "error_msg=" . $ex->getMessage());
return false;
}
}
public function delInfoByUserId($userId)
{
$tag = __CLASS__ . "-" . __FILE__;
$startTime = microtime(true);
try {
$sql = "delete from $this->table where userId=:userId";
$prepare = $this->db->prepare($sql);
$this->handlePrepareError($tag, $prepare);
$prepare->bindValue(":usrId", $userId);
$prepare->execute();
$this->ctx->Wpf_Logger->writeSqlLog($tag, $sql, $userId, $startTime);
} catch (Exception $ex) {
$this->ctx->Wpf_Logger->error($tag, "error_msg=" . $ex->getMessage());
throw new Exception("delete failed");
return false;
}
}
}