JSlip  1.0
LoginModel.php
Go to the documentation of this file.
1 <?php
8 require_once(dirname(__FILE__) . '/../../lib/Model.php');
9 
10 class LoginModel extends Model
11 {
12  public function chkPasswd($account, $passwd) {
13 
14  $this->connect();
15  $sql = "SELECT `password` FROM `t_auth` WHERE `login_id` = '" . $this->esc($account) . "'";
16  $rec = $this->getRecord($sql);
17  $this->close();
18 
19  return (empty($rec[0])) ? false : password_verify($passwd, $rec[0]['password']);
20  }
21 
22  public function getMemberInfo($account) {
23 
24  $this->connect();
25  $sql = "SELECT `m`.`mid`, `m`.`name`, `m`.`role`"
26  . " FROM `t_auth` `a`"
27  . " INNER JOIN `t_member` `m` ON `a`.`aid` = `m`.`aid`"
28  . " WHERE `a`.`login_id` = '" . $this->esc($account) . "'"
29  ;
30  $rec = $this->getRecord($sql);
31  $this->close();
32 
33  return (empty($rec[0])) ? [] : $rec[0];
34  }
35 
36  public function cntBasic($mid) {
37 
38  $this->connect();
39  $sql = "SELECT COUNT(*) AS `cnt`"
40  . " FROM `t_basic`"
41  . " WHERE `mid` = '" . $this->esc($mid) . "'"
42  . " AND `valid_flg` IS TRUE"
43  ;
44  $rec = $this->getRecord($sql);
45  $this->close();
46 
47  return $rec[0]['cnt'] * 1;
48  }
49 
50  public function getBid($mid) {
51 
52  $this->connect();
53  $sql = "SELECT `id`"
54  . " FROM `t_basic`"
55  . " WHERE `mid` = '" . $this->esc($mid) . "'"
56  . " AND `valid_flg` IS TRUE"
57  ;
58  $rec = $this->getRecord($sql);
59  $this->close();
60 
61  return (empty($rec[0]['id'])) ? -1 : $rec[0]['id'];
62  }
63 }
LoginModel\chkPasswd
chkPasswd($account, $passwd)
Definition: LoginModel.php:12
Model\connect
connect()
Definition: Model.php:12
Model\getRecord
getRecord($sql)
Definition: Model.php:55
Model
Definition: Model.php:8
LoginModel\getBid
getBid($mid)
Definition: LoginModel.php:50
LoginModel\getMemberInfo
getMemberInfo($account)
Definition: LoginModel.php:22
Model\close
close()
Definition: Model.php:27
Model\esc
esc($str)
Definition: Model.php:43
LoginModel\cntBasic
cntBasic($mid)
Definition: LoginModel.php:36
LoginModel
Definition: LoginModel.php:10