/
Hospital.php
73 lines (67 loc) · 1.82 KB
/
Hospital.php
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
<?php
class Application_Model_M_Hospital extends Application_Model_M_B_Hospital{
/*
* 通过邮箱和密码查询
*/
public static function fetchByEmailAndPasswd($email,$passwd){
$select = self::select();
$select
->where('email = ?',$email)
->where('passwd = ?',$passwd)
->where('status = 1')
;
$data = self::fetchAll($select);
return $data?$data[0]:NULL;
}
/*
* 通过邮箱查找
* @param email
* @return bool
*/
public static function fetchByEmail($email){
$select = self::select();
$select
->where('email = ?',$email)
;
$data = self::fetchAll($select);
if(count($data)>0){
return true;
}else{
return false;
}
}
/*
* 通过医院名称查找医院
*/
public static function fetchByName($name){
if(!$name){
return array();
}
$select = self::select();
$select
->where("name like '%{$name}%'")
->where('status = 1')
;
$data = self::fetchAll($select);
return $data;
}
public static function getAvatarUrl($id){
$url = '/hospital/image?id='.$id;
return $url;
}
public static function updateAvatar($id,$avatar){
$sql = "UPDATE yy_hospital SET avatar = '{$avatar}' WHERE id = {$id}";
$config = self::getDb()->getConfig();
$pdo = new PDO("mysql:host={$config['host']};dbname={$config['dbname']}", $config['username'], $config['password']);
return $pdo->exec($sql);
}
public static function getAvatar($id){
$sql = "SELECT avatar FROM yy_hospital WHERE id={$id}";
$res = self::getDb()->query($sql)->fetchAll();
$avatar = "";
if(count($res)>0){
$avatar = $res['0']['avatar'];
}
return $avatar;
}
}