public function addStudentRequestAction()
 {
     $student_id = $_GET["student_id"];
     $request_id = $_GET["request_id"];
     $tableList = $_GET["tableList"];
     $request = new Request();
     $request->setRequestId($request_id);
     $request->setStudentId($student_id);
     $request->setRequestDate(date("Y-m-d"));
     $resourcesArray = array();
     //$tableList =json_decode($tableList);
     $cout = 0;
     for ($x = 0; $x < count($tableList); $x += 1) {
         $cout++;
         $requestResource = new RequestResource();
         $requestResource->setRequestId($request_id);
         $requestResource->setResourceId($tableList[$x][0]);
         $requestResource->setQty($tableList[$x][2]);
         $requestResource->setItemBorrowingDate($tableList[$x][3]);
         $requestResource->setReturnDate($tableList[$x][4]);
         $resourcesArray[] = $requestResource;
     }
     $status = StudentRequestDBaccess::addStudentRequest($request, $resourcesArray);
     $v = $resourcesArray[0];
     return new JsonResponse(['status' => $status]);
 }
 public static function addStudentRequest(Request $request, array $requestResource)
 {
     try {
         $conn = connection::getConnectionObject();
         $con = $conn->getConnection();
         $con->autocommit(false);
         $sql = $con->prepare("INSERT INTO Request VALUES (?,?,?,?)");
         $requestId = $request->getRequestId();
         $studentId = $request->getStudentId();
         $date = $request->getRequestDate();
         $status = "pending";
         $sql->bind_param("ssss", $requestId, $studentId, $date, $status);
         if ($sql->execute() == TRUE) {
             foreach ($requestResource as $value) {
                 $isAdded = StudentRequestDBaccess::addRequestResource($con, $value);
                 if ($isAdded == false) {
                     $con->rollback();
                     return false;
                 }
             }
         } else {
             $con->rollback();
             return false;
         }
         $con->commit();
         return true;
     } catch (Exception $e) {
         $con->rollback();
         return false;
     } finally {
         $con->autocommit(true);
         $con->close();
     }
 }