You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							65 lines
						
					
					
						
							2.5 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							65 lines
						
					
					
						
							2.5 KiB
						
					
					
				
								<?php
							 | 
						|
								
							 | 
						|
								use App\Enumerators\SessionElement;
							 | 
						|
								use App\Wrappers\DatabaseInteractions;
							 | 
						|
								use App\Wrappers\SessionWrapper;
							 | 
						|
								use App\Wrappers\SQLQueryBuilderWrapper;
							 | 
						|
								use Ramsey\Uuid\Uuid;
							 | 
						|
								
							 | 
						|
								require_once __DIR__ . "/../../vendor/autoload.php";
							 | 
						|
								
							 | 
						|
								$tuneTitle = $_POST['TuneTitle'];
							 | 
						|
								$tuneCopyright = $_POST['TuneCopyright'];
							 | 
						|
								
							 | 
						|
								$parts = [];
							 | 
						|
								
							 | 
						|
								foreach ($_POST as $key => $value) {
							 | 
						|
								    if (preg_match('/^PartTimeSignature-Part([A-Z])$/', $key, $matches)) {
							 | 
						|
								        $partLetter = $matches[1];
							 | 
						|
								        $parts[$partLetter]['TimeSignature'] = $value;
							 | 
						|
								    } elseif (preg_match('/^PartKeySignature-Part([A-Z])$/', $key, $matches)) {
							 | 
						|
								        $partLetter = $matches[1];
							 | 
						|
								        $parts[$partLetter]['KeySignature'] = $value;
							 | 
						|
								    } elseif (preg_match('/^TextArea-Part([A-Z])$/', $key, $matches)) {
							 | 
						|
								        $partLetter = $matches[1];
							 | 
						|
								        $parts[$partLetter]['ABCNotation'] = $value;
							 | 
						|
								    }
							 | 
						|
								}
							 | 
						|
								
							 | 
						|
								ksort($parts);
							 | 
						|
								
							 | 
						|
								$db = new DatabaseInteractions();
							 | 
						|
								$id = Uuid::uuid4()->toString();
							 | 
						|
								
							 | 
						|
								$db->RunInsert(
							 | 
						|
								    queryBuilder: SQLQueryBuilderWrapper::INSERT('Tunes')
							 | 
						|
								        ->set(col: 'ID', value: ':__id__')
							 | 
						|
								        ->set(col: 'CreatedBy', value: ':__created_by__')
							 | 
						|
								        ->set(col: 'Title', value: ':__tune_title__')
							 | 
						|
								        ->set(col: 'Copyright', value: ':__copyright__')
							 | 
						|
								        ->bindValue(name: '__id__', value: $id)
							 | 
						|
								        ->bindValue(name: '__created_by__', value: SessionWrapper::Get(SessionElement::USER_ID))
							 | 
						|
								        ->bindValue(name: '__tune_title__', value: $tuneTitle)
							 | 
						|
								        ->bindValue(name: '__copyright__', value: $tuneCopyright)
							 | 
						|
								);
							 | 
						|
								
							 | 
						|
								foreach ($parts as $partLetter => $part) {
							 | 
						|
								    $db->RunInsert(
							 | 
						|
								        queryBuilder: SQLQueryBuilderWrapper::INSERT('TuneParts')
							 | 
						|
								            ->set(col: 'CreatedBy', value: ':__created_by__')
							 | 
						|
								            ->set(col: 'TuneID', value: ':__tune_id__')
							 | 
						|
								            ->set(col: 'TimeSignature', value: ':__time_signature__')
							 | 
						|
								            ->set(col: 'KeySignature', value: ':__key_signature__')
							 | 
						|
								            ->set(col: 'PartLetter', value: ':__part_letter__')
							 | 
						|
								            ->set(col: 'ABCNotation', value: ':__abc_notation__')
							 | 
						|
								            ->bindValue(name: '__created_by__', value: SessionWrapper::Get(SessionElement::USER_ID))
							 | 
						|
								            ->bindValue(name: '__tune_id__', value: $id)
							 | 
						|
								            ->bindValue(name: '__time_signature__', value: $part['TimeSignature'])
							 | 
						|
								            ->bindValue(name: '__key_signature__', value: $part['KeySignature'])
							 | 
						|
								            ->bindValue(name: '__part_letter__', value: $partLetter)
							 | 
						|
								            ->bindValue(name: '__abc_notation__', value: $part['ABCNotation'])
							 | 
						|
								    );
							 | 
						|
								}
							 | 
						|
								
							 | 
						|
								header("Location: /tune/{$id}");
							 | 
						|
								die();
							 | 
						|
								
							 |