-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuserDao.class.php
75 lines (50 loc) · 1.1 KB
/
userDao.class.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
74
75
<?php
class VChainUserDao
{
public static function get($params = array())
{
$output = array();
$m = new MongoClient();
$db = $m->vchain;
$collection = $db->users;
$cursor = $collection->find($params);
foreach ($cursor as $document)
{
$document["id"] = (string) $document["_id"];
unset($document["_id"]);
$output[] = $document;
}
return $output;
}
public static function create($identity_id, $email, $phone)
{
$m = new MongoClient();
$db = $m->vchain;
$collection = $db->users;
$current_time = time();
$data = array();
$data["created"] = $current_time;
$data["identity_id"] = $identity_id;
$data["email"] = $email;
$data["phone"] = $phone;
$data["status"] = USER_STATUS_NOT_ACTIVATED;
$collection->insert($data);
$data["id"] = (string) $data["_id"];
unset($data["_id"]);
return $data;
}
public static function update($user_id, $params)
{
$m = new MongoClient();
$db = $m->vchain;
$collection = $db->users;
$collection->update(
array( "_id" => new MongoId($user_id) ),
array(
'$set' => $params
)
);
return true;
}
}
?>