Exemplo n.º 1
0
 /**
  * Function to create new task, validate and save it to DB
  * @param $new_task - user input - task
  */
 public function createNewTask($new_task)
 {
     $new_task = Validate::cleanInput($new_task);
     if ($new_task != "") {
         //not to allow to add empty task
         $conn = Model\Db::getConnection();
         $query_to_create_new_task = 'INSERT INTO `task`(`date`, `name`, `is_done`, `is_deleted`, `time`) VALUES (?, ?, ?, ?, ?)';
         $stmt = $conn->prepare($query_to_create_new_task);
         $stmt->bindParam(1, $date);
         $stmt->bindParam(2, $name);
         $stmt->bindParam(3, $is_done);
         $stmt->bindParam(4, $is_deleted);
         $stmt->bindParam(5, $time);
         $stmt->execute();
         $date = date("Y-m-d");
         $name = $new_task;
         $is_done = 0;
         $is_deleted = 0;
         $time = date("H:i:s");
         $stmt->execute();
     }
 }