JSlip  1.0
UserAccountModel.php
Go to the documentation of this file.
1 <?php
8 require_once(dirname(__FILE__) . '/../../lib/Model.php');
9 
10 class UserAccountModel extends Model
11 {
12  public function getData($bid) {
13 
14  $this->connect();
15  $sql = "SELECT `a`.`login_id`, `m`.*"
16  . " FROM `t_basic` `b`"
17  . " INNER JOIN `t_member` `m` ON `b`.`mid` = `m`.`mid`"
18  . " INNER JOIN `t_auth` `a` ON `m`.`aid` = `a`.`aid`"
19  . " WHERE `b`.`id` = '" . $this->esc($bid) . "'"
20  ;
21  $rec = $this->getRecord($sql);
22  $this->close();
23 
24  return (empty($rec[0])) ? [] : $rec[0];
25  }
26 
27  public function regist($param) {
28 
29  $err = '';
30 
31  $this->connect();
32  $this->begin();
33 
34  try {
35 
36  if (!empty($param['passwd1'])) {
37  $sql = "UPDATE `t_auth` SET"
38  . " `password`" . " = '" . password_hash($param['passwd1'], PASSWORD_DEFAULT) . "'"
39  . ", `update_person`" . " = " . $_SESSION['minfo']['mid']
40  . " WHERE `aid` = '" . $this->esc($param['aid']) . "'"
41  ;
42  $ans = $this->query($sql);
43  }
44 
45  $sql = "UPDATE `t_member` SET"
46  . " `name`" . " = '" . $this->esc($param['name']) . "'"
47  . ", `email`" . " = '" . $this->esc($param['email']) . "'"
48  . ", `tel`" . " = '" . $this->esc($param['tel']) . "'"
49  . ", `update_person`" . " = " . $_SESSION['minfo']['mid']
50  . " WHERE `mid` = '" . $this->esc($param['mid']) . "'"
51  ;
52  $ans = $this->query($sql);
53 
54  } catch(Exception $e) {
55  $err = $e->getMessage();
56  }
57 
58  if (empty($err)) {
59  $this->commit();
60  } else {
61  $this->rollback();
62  }
63 
64  $this->close();
65 
66  return $err;
67  }
68 }
Model\connect
connect()
Definition: Model.php:12
Model\begin
begin()
Definition: Model.php:31
Model\query
query($sql)
Definition: Model.php:47
Model\getRecord
getRecord($sql)
Definition: Model.php:55
UserAccountModel\regist
regist($param)
Definition: UserAccountModel.php:27
Model
Definition: Model.php:8
Model\commit
commit()
Definition: Model.php:35
Model\close
close()
Definition: Model.php:27
Model\esc
esc($str)
Definition: Model.php:43
UserAccountModel\getData
getData($bid)
Definition: UserAccountModel.php:12
UserAccountModel
Definition: UserAccountModel.php:10
Model\rollback
rollback()
Definition: Model.php:39