Skip to content

Commit fff028e

Browse files
committed
Merge pull request aces#70 from rathisekaran/Project_SubprojLink
adding getValidSubprojects to Candidate class
2 parents 124f320 + 0d4cb30 commit fff028e

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

libraries/Candidate.class.inc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,34 @@ class Candidate
566566

567567
return $arrays;
568568
}
569+
/**
570+
* generates list of valid subprojects for a given project id
571+
* @static
572+
* @return array
573+
* @throws Utility::isErrorX
574+
*/
575+
function getValidSubprojects()
576+
{
577+
$projID = $this->getProjectID();
578+
$db =& Database::singleton();
579+
if(Utility::isErrorX($db)) {
580+
return PEAR::raiseError("Could not connect to database: ".$db->getMessage());
581+
}
582+
$query = "SELECT SubprojectID from project_rel where ProjectID = :prj";
583+
$params = array('prj'=>$projID);
584+
$subproj = $db->pselect($query, $params);
585+
if(Utility::isErrorX($subproj)) {
586+
return PEAR::raiseError("Could not connect to database: ".$subproj->getMessage());
587+
}
588+
foreach($subproj as $row){
589+
foreach($row as $key =>$val){
590+
if($key == 'SubprojectID') {
591+
$subprojList[$val] = $val;
592+
}
593+
}
594+
}
595+
return $subprojList;
596+
}
569597

570598
}
571599
?>

tables_sql/Add_projrel.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE TABLE `project_rel` (
2+
`ProjectID` int(2) DEFAULT NULL,
3+
`SubprojectID` int(2) DEFAULT NULL
4+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
5+
6+
INSERT INTO `project_rel` VALUES (1,1),(1,2),(1,3),(1,7),(2,9),(2,10),(3,4),(3,5),(3,7),(4,6);

0 commit comments

Comments
 (0)