Changeset 130 for Dev/branches/jos-branch/classes/DatabaseInterface.php
- Timestamp:
- 10/24/11 13:47:23 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/jos-branch/classes/DatabaseInterface.php
r128 r130 17 17 * Constructor for the DatabaseInterface class 18 18 */ 19 protected $applicationConnector; 19 private $applicationConnector; 20 private $questionConnector; 21 private $userConnector; 20 22 23 /** 24 * Constructor for DatabaseInterface. 25 * Initializes all the connectors. 26 */ 21 27 public function __construct() { 22 28 $this->applicationConnector = new ApplicationConnector(); 29 $this->questionConnector = new QuestionConnector(); 30 $this->userConnector = new UserConnector(); 23 31 } 24 32 33 /** 34 * Get the data corresponding to the given type and arguments 35 * @param type $type 36 * @param type $arguments 37 * @return type 38 */ 25 39 public function get($type, $arguments) 26 40 { 27 switch( $type)41 switch(strtolower($type)) 28 42 { 29 43 case "application": 30 44 return $this->applicationConnector->get($arguments); 31 45 break; 46 case "question": 47 return $this->questionConnector->get($arguments); 48 break; 49 case "user": 50 return $this->userConnector->get($arguments); 51 break; 32 52 } 33 53 } 34 54 35 public function set($rToolObject) 36 { 37 switch(get_class($rToolObject)) 38 { 39 case "Application": 40 $this->applicationConnector->set($rToolObject); 41 } 42 } 43 55 /** 56 * Saves the given object based on its class. 57 * @param type $rToolObject 58 */ 59 public function set($rToolObject) 60 { 61 switch(get_class($rToolObject)) 62 { 63 case "Application": 64 $this->applicationConnector->set($rToolObject); 65 break; 66 case "Question": 67 $this->questionConnector->set($rToolObject); 68 break; 69 case "User": 70 $this->userConnector->set($rToolObject); 71 break; 72 } 73 } 74 75 /** 76 * Saves all the objects in the given array, assuming they are 77 * valid ResearchToolObjects. 78 * @param type $rToolObjects 79 */ 80 public function batchSet($rToolObjects) 81 { 82 foreach ($rToolObjects as $rToolObject) 83 { 84 $this->set($rToolObject); 85 } 86 } 87 44 88 45 89 }
Note: See TracChangeset
for help on using the changeset viewer.