Esempio n. 1
0
 /**
  * @Route("/testdb",name="database")
  */
 public function test()
 {
     $member = new Entity\Member();
     $member->setMobile("07129832");
     $member->setRegisterDate("12/12/2012");
     $member->setEmail("*****@*****.**");
     $member->setFirstName("Nuwan");
     $member->setLastName("Rathnayaka");
     $member->setStudentId("123456F");
     $member->setDeptName("noone");
     $r = new Entity\Resource();
     $r->setResourceId("1");
     $r->setDescription("this  description");
     $r->setOfficerId("1234");
     $r->setValue("sdsds");
     $ra = new Entity\ResourceAllocation();
     $ra->setResourceId("1");
     $ra->setMemberId("123456F");
     $ra->setComments("Use enjoy it");
     $ra->setDueDate("2016-01-07");
     $ra->setIssuedDate("2015-12-34");
     $testdb = new Modal\DBAccess($r);
     $testdb->update();
     return new Response();
 }
Esempio n. 2
0
 public function getDetail()
 {
     $db = new DBConnection();
     if ($db->connect()) {
         if ($this->entity_type == 'Member') {
             $member = new Member();
             $query = "SELECT * FROM member WHERE s_ID = '" . $this->entity->getStudentId() . "'";
             $result = $db->executeQuery($query);
             while ($row = mysqli_fetch_assoc($result)) {
                 $member->setStudentId($row['s_ID']);
                 $member->setFirstName($row['first_name']);
                 $member->setLastName($row['last_name']);
                 $member->setDeptName($row['dept_name']);
                 $member->setRegisterDate($row['register_date']);
                 $member->setEmail($row['email']);
                 $member->setMobile($row['mobile']);
             }
             $db->closeConnection();
             return $member;
         } elseif ($this->entity_type == 'Resource') {
             $resource = new Resource();
             $resource->setResourceId($this->entity->getResourceId());
             $query = "SELECT * FROM resource WHERE r_ID='" . $this->entity->getResourceId() . "'";
             $result = $db->executeQuery($query);
             while ($row = mysqli_fetch_assoc($result)) {
                 $resource->setResourceId($row['r_ID']);
                 $resource->setValue($row['value']);
                 $resource->setDescription($row['description']);
                 $resource->setOfficerId($row['o_ID']);
             }
             $db->closeConnection();
             return $resource;
         } elseif ($this->entity_type == 'ResourceAllocation') {
             $resourceAlloc = new ResourceAllocation();
             $query = "SELECT * FROM resource_alloc WHERE r_ID ='" . $this->entity->getResourceId() . "' AND s_ID = '" . $this->entity->getMemberId() . "'";
             $result = $db->executeQuery($query);
             while ($row = mysqli_fetch_assoc($result)) {
                 $resourceAlloc->setMemberId($row['s_ID']);
                 $resourceAlloc->setResourceId($row['r_ID']);
                 $resourceAlloc->setComments($row['comments']);
                 $resourceAlloc->setIssuedDate($row['issued_date']);
                 $resourceAlloc->setDueDate($row['due_date']);
             }
             $db->closeConnection();
             return $resourceAlloc;
         }
     } else {
         echo "Cannot connect to database";
     }
 }