<commit_before><?php
// 	header("Content-type: text/xml"); 
include ('database.php');

	$statement = $connection->prepare ("INSERT INTO tblPRACTICE (DateID, GroupID, PracticeTypeID, StartTime, EndTime) 
   	VALUES (:dateid, :groupid, :practicetypeid, :starttime, :endtime)");
    $statement2 = $connection->prepare ("INSERT INTO tblPLAYER_PRACTICE (PlayerID, PracticeID) 
   	VALUES (:playerid, :practiceid)");
   	$statement3 = $connection->prepare ("INSERT INTO tblDATE (DateName) 
   	VALUES (:datename)");
	
   	if (isset($_POST['uid']) && isset($_POST['time'])) {
		$groupID = $_POST['uid'];
		$tData = $_POST['time'];
		$timeData = explode('_', $tData);
		$time = $timeData[0];
		$day = $timeData[1];
		$month = $timeData[2];
		$year = $timeData[3];
		$num_length = strlen((string)$month);
		
		if ($num_length < 2){
			$month = '0'.$month;
		}

		$date = $year.$month.$day;

		$datequery = $connection->query("Select DateID from tblDATE where DateName = '$date'");
		$datequery->execute();

		if($datequery->rowCount() < 1)
		{
		    // row exists. do whatever you want to do.
		    $statement3 -> execute(array(':datename' => $date));
		} 

		$dateids = $datequery->fetch(PDO::FETCH_ASSOC);
		$dateid = $dateids['DateID'];

		$practicequery = $connection->query("Select * from tblPRACTICE WHERE GroupID = $groupID AND DateID = $dateid");
		$practicequery->execute();
		$practiceid = 1;


		if($practicequery->rowCount() < 1)
		{
		    // row exists. do whatever you want to do.
		   $statement -> execute(array(':dateid' => $dateid, 
					':groupid' => $groupID, 
					':practicetypeid' => 1, 
					':starttime' => $time,
					':endtime' => NULL));

		} else {
			$practiceData = $practicequery->fetch(PDO::FETCH_ASSOC);
			$practiceid = $practiceData['PracticeID'];
			$checkTime = true;

			foreach($practicequery as $row) {
				$starttime = $row['StartTime'];
				if ($row['EndTime'] == NULL) {
					$updatepractice = $connection->query("UPDATE tblPRACTICE SET EndTime = '$time' WHERE GroupID = $groupID AND DateID = $dateid AND StartTime = '$starttime'");
					$updatepractice->execute();
					$checkTime = false;
					$practiceid = $row['PracticeID'];
					insertPlayers($practiceid);
				}
			}

			if($checkTime) {
				  $statement -> execute(array(':dateid' => $dateid, 
					':groupid' => $groupID, 
					':practicetypeid' => 1, 
					':starttime' => $time,
					':endtime' => NULL));
			}
		}

		function insertPlayers($practiceid){
			foreach($connection->query("Select * from tblPLAYER_GROUP pg WHERE pg.GroupID = $groupID") as $row) {
				$statement2 -> execute(array(':playerid' => $row['PlayerID'], 
				':practiceid' => $practiceid));
			}

		}
	// 	$db = $sql_
		
		echo($uid);
	}
	echo "this is up!";
	?><commit_msg>it works?<commit_after><?php
// 	header("Content-type: text/xml"); 
include ('database.php');

	$statement = $connection->prepare ("INSERT INTO tblPRACTICE (DateID, GroupID, PracticeTypeID, StartTime, EndTime) 
   	VALUES (:dateid, :groupid, :practicetypeid, :starttime, :endtime)");
    $statement2 = $connection->prepare ("INSERT INTO tblPLAYER_PRACTICE (PlayerID, PracticeID) 
   	VALUES (:playerid, :practiceid)");
   	$statement3 = $connection->prepare ("INSERT INTO tblDATE (DateName) 
   	VALUES (:datename)");
	//echo "works: " . $_GET['uid'];
   	if (isset($_GET['uid']) && isset($_GET['time'])) {
   		echo "did it work?";
		$groupID = $_GET['uid'];
		$tData = $_GET['time'];
		$timeData = explode('_', $tData);
		$time = $timeData[0];
		$day = $timeData[1];
		$month = $timeData[2];
		$year = $timeData[3];
		$num_length = strlen((string)$month);
		
		if ($num_length < 2){
			$month = '0'.$month;
		}

		$date = $year.$month.$day;

		$datequery = $connection->query("Select DateID from tblDATE where DateName = '$date'");
		$datequery->execute();

		if($datequery->rowCount() < 1)
		{
		    // row exists. do whatever you want to do.
		    $statement3 -> execute(array(':datename' => $date));
		} 

		$dateids = $datequery->fetch(PDO::FETCH_ASSOC);
		$dateid = $dateids['DateID'];

		$practicequery = $connection->query("Select * from tblPRACTICE WHERE GroupID = $groupID AND DateID = $dateid");
		$practicequery->execute();
		$practiceid = 1;


		if($practicequery->rowCount() < 1)
		{
		    // row exists. do whatever you want to do.
		   $statement -> execute(array(':dateid' => $dateid, 
					':groupid' => $groupID, 
					':practicetypeid' => 1, 
					':starttime' => $time,
					':endtime' => ''));

		} else {
			$practiceData = $practicequery->fetch(PDO::FETCH_ASSOC);
			$practiceid = $practiceData['PracticeID'];
			$checkTime = true;

			foreach($practicequery as $row) {
				$starttime = $row['StartTime'];
				if ($row['EndTime'] == '') {
					$updatepractice = $connection->query("UPDATE tblPRACTICE SET EndTime = '$time' WHERE GroupID = $groupID AND DateID = $dateid AND StartTime = '$starttime'");
					$updatepractice->execute();
					$checkTime = false;
					$practiceid = $row['PracticeID'];
					insertPlayers($practiceid);
				}
			}

			if($checkTime) {
				  $statement -> execute(array(':dateid' => $dateid, 
					':groupid' => $groupID, 
					':practicetypeid' => 1, 
					':starttime' => $time,
					':endtime' => ''));
			}
		}

		function insertPlayers($practiceid){
			foreach($connection->query("Select * from tblPLAYER_GROUP pg WHERE pg.GroupID = $groupID") as $row) {
				$statement2 -> execute(array(':playerid' => $row['PlayerID'], 
				':practiceid' => $practiceid));
			}

		}
	// 	$db = $sql_
		
		echo($groupID);
	}
	echo "this is up!";
	?>
{'fraction_non_alphanumeric': 0.19215473608098338, 'fraction_numerical': 0.005422993492407809, 'mean_word_length': 3.712947189097104, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2286243', 'n_tokens_mistral': 2310, 'n_tokens_neox': 1899, 'n_words': 399}