Ejemplo n.º 1
0
 public function updateFramework()
 {
     // check database connections
     $conn = $this->databaseConnection();
     parse_str(file_get_contents("php://input"), $post_vars);
     $id = $post_vars['ID'];
     $birthDate = trim($post_vars['BirthDate']);
     $firstName = trim($post_vars['FirstName']);
     $lastName = trim($post_vars['LastName']);
     $gender = trim($post_vars['Gender']);
     $hireDate = trim($post_vars['HireDate']);
     if ($conn) {
         $queries = new Queries();
         $sqlCheck = $queries->checkFrameworkIfExistsById($id);
         $checkResult = mysqli_query($conn, $sqlCheck);
         if (mysqli_num_rows($checkResult) <= 0) {
             echo json_encode(array('error' => $id . ' does not exist.'));
         } else {
             $sqlQuery = $queries->updateFrameworkQuery($id, $birthDate, $firstName, $lastName, $gender, $hireDate);
             $result = mysqli_query($conn, $sqlQuery);
             if ($result) {
                 echo json_encode(array('success' => 'Updated ' . $id));
             } else {
                 echo json_encode(array('error' => 'Unable to Update ' . $id));
             }
         }
     } else {
         $connection = false;
         echo "There was an error, please contact web administrator.";
         return false;
     }
 }
 public function updateFramework()
 {
     // check database connections
     $conn = $this->databaseConnection();
     parse_str(file_get_contents("php://input"), $post_vars);
     $id = $post_vars['id'];
     $framework = trim($post_vars['framework']);
     $language = trim($post_vars['language']);
     $link = trim($post_vars['link']);
     $description = trim($post_vars['description']);
     if ($conn) {
         $queries = new Queries();
         $sqlCheck = $queries->checkFrameworkIfExistsById($id);
         $checkResult = mysqli_query($conn, $sqlCheck);
         if (mysqli_num_rows($checkResult) <= 0) {
             echo json_encode(array('error' => $framework . ' does not exist.'));
         } else {
             $sqlQuery = $queries->updateFrameworkQuery($id, $framework, $language, $link, $description);
             $result = mysqli_query($conn, $sqlQuery);
             if ($result) {
                 echo json_encode(array('success' => 'Updated ' . $framework));
             } else {
                 echo json_encode(array('error' => 'Unable to Update ' . $framework));
             }
         }
     } else {
         $connection = false;
         echo "There was an error, please contact web administrator.";
         return false;
     }
 }