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
/**
* Project DAO class file.
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @link https://github.com/pradosoft/prado
* @copyright Copyright © 2005-2006 PradoSoft
* @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
* @package Demos
*/
/**
* Project DAO class.
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @package Demos
* @since 3.1
*/
class ProjectDao extends BaseDao
{
public function projectNameExists($projectName)
{
$sqlmap = $this->getSqlMap();
return $sqlmap->queryForObject('ProjectNameExists', $projectName);
}
public function addNewProject($project)
{
$sqlmap = $this->getSqlMap();
$sqlmap->insert('CreateNewProject', $project);
}
public function getProjectByID($projectID)
{
$sqlmap = $this->getSqlMap();
return $sqlmap->queryForObject('GetProjectByID', $projectID);
}
public function deleteProject($projectID)
{
$sqlmap = $this->getSqlMap();
$sqlmap->update('DeleteProject',$projectID);
}
public function addUserToProject($projectID, $username)
{
$sqlmap = $this->getSqlMap();
$members = $this->getProjectMembers($projectID);
if(!in_array($username, $members))
{
$param['username'] = $username;
$param['project'] = $projectID;
$sqlmap->insert('AddUserToProject',$param);
}
}
public function getProjectMembers($projectID)
{
$sqlmap = $this->getSqlMap();
return $sqlmap->queryForList('GetProjectMembers', $projectID);
}
public function getAllProjects($sort='', $order='ASC')
{
$sqlmap = $this->getSqlMap();
if($sort === '')
return $sqlmap->queryForList('GetAllProjects');
else
{
$param['sort'] = $sort;
$param['order'] = $order;
return $sqlmap->queryForList('GetAllProjectsOrdered', $param);
}
}
public function getProjectsByManagerName($manager)
{
$sqlmap = $this->getSqlMap();
return $sqlmap->queryForList('GetProjectsByManagerName', $manager);
}
public function getProjectsByUserName($username)
{
$sqlmap = $this->getSqlMap();
return $sqlmap->queryForList('GetProjectsByUserName', $username);
}
public function removeUserFromProject($projectID, $username)
{
$sqlmap = $this->getSqlMap();
$param['username'] = $username;
$param['project'] = $projectID;
$sqlmap->delete('RemoveUserFromProject', $param);
}
public function updateProject($project)
{
$sqlmap = $this->getSqlMap();
$sqlmap->update('UpdateProject', $project);
}
}
|