示例#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();
 }
示例#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";
     }
 }
示例#3
0
 public function getDetail()
 {
     $db = new DBConnection();
     $link = $db->connect();
     if ($link) {
         if ($this->entity_type == 'Member') {
             $member = new Member();
             $query = "SELECT * FROM member WHERE id = " . $this->entity->getStudentId();
             $result = $link->query($query);
             while ($row = mysqli_fetch_assoc($result)) {
                 $member->setStudentId($row['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']);
                 $member->setIndexNu($row['index_no']);
                 $member->setBirthday($row['birthday']);
                 $member->setGender($row['gender']);
                 $member->setFacultyname($row['faculty_name']);
                 $member->setNic($row['NIC']);
             }
             $db->closeConnection();
             return $member;
         } elseif ($this->entity_type == 'Resource') {
             $resource = new Resource();
             foreach ($this->entity as $property => $value) {
                 $resource->{$property}($value);
             }
             $query = "SELECT * FROM resource WHERE r_ID='" . $resource->getResourceId() . "'";
             $result = $db->executeQuery($query);
             while ($row = mysqli_fetch_assoc($result)) {
                 $resource->setResourceId($row[1]);
                 $resource->setCategory($row[2]);
                 $resource->setDescription($row[3]);
                 $resource->setOfficerId($row[4]);
             }
             $db->closeConnection();
             return $resource;
         } elseif ($this->entity_type == 'DynamicAllocation') {
             $resourceAlloc = new ResourceAllocation();
             foreach ($this->entity as $property => $value) {
                 $resourceAlloc->{$property}($value);
             }
             $query = "SELECT * FROM dynamic_alloc WHERE r_ID ='" . $resourceAlloc->getResourceId() . "' AND s_ID = '" . $resourceAlloc->getMemberId() . "'";
             $result = $db->executeQuery($query);
             while ($row = mysqli_fetch_assoc($result)) {
                 $resourceAlloc->setComments($row[2]);
                 $resourceAlloc->setIssuedDate($row[3]);
                 $resourceAlloc->setDueDate($row[4]);
             }
             $db->closeConnection();
             return $resourceAlloc;
         }
     } else {
         echo "Cannot connect to database";
     }
 }
示例#4
0
 public function getDetail()
 {
     $db = new DBConnection();
     if ($db->connect()) {
         if ($this->entity_type == 'Member') {
             $member = new Member();
             foreach ($this->entity as $property => $value) {
                 $member->{$property}($value);
             }
             $query = "SELECT * FROM member WHERE s_ID = '" . $member->getStudentId() . "'";
             $result = $db->executeQuery($query);
             while ($row = mysqli_fetch_assoc($result)) {
                 $member->setFirstName($row[1]);
                 $member->setLastName($row[2]);
                 $member->setDeptName($row[3]);
                 $member->setRegisterDate($row[4]);
                 $member->setEmail($row[5]);
                 $member->setMobile($row[6]);
             }
             $db->closeConnection();
             return $member;
         } elseif ($this->entity_type == 'Resource') {
             $resource = new Resource();
             foreach ($this->entity as $property => $value) {
                 $resource->{$property}($value);
             }
             $query = "SELECT * FROM resource WHERE r_ID='" . $resource->getResourceId() . "'";
             $result = $db->executeQuery($query);
             while ($row = mysqli_fetch_assoc($result)) {
                 $resource->setResourceId($row[1]);
                 $resource->setValue($row[2]);
                 $resource->setDescription($row[3]);
                 $resource->setOfficerId($row[4]);
             }
             $db->closeConnection();
             return $resource;
         } elseif ($this->entity_type == 'ResourceAllocation') {
             $resourceAlloc = new ResourceAllocation();
             foreach ($this->entity as $property => $value) {
                 $resourceAlloc->{$property}($value);
             }
             $query = "SELECT * FROM resource_alloc WHERE r_ID ='" . $resourceAlloc->getResourceId() . "' AND s_ID = '" . $resourceAlloc->getMemberId() . "'";
             $result = $db->executeQuery($query);
             while ($row = mysqli_fetch_assoc($result)) {
                 $resourceAlloc->setComments($row[2]);
                 $resourceAlloc->setIssuedDate($row[3]);
                 $resourceAlloc->setDueDate($row[4]);
             }
             $db->closeConnection();
             return $resourceAlloc;
         }
     } else {
         echo "Cannot connect to database";
     }
 }