src/QueryBuilder.php
protected function _compileType(string $type='', string $table=''): string
	{
		$setArrayKeys = $this->state->getSetArrayKeys();
		switch($type)
		{
			case 'insert':
				$paramCount = count($setArrayKeys);
				$params = array_fill(0, $paramCount, '?');
				$sql = "INSERT INTO {$table} ("
					. implode(',', $setArrayKeys)
					. ")\nVALUES (".implode(',', $params).')';
				break;

			case 'update':
				$setString = $this->state->getSetString();
				$sql = "UPDATE {$table}\nSET {$setString}";
				break;

			case 'replace':
				// @TODO implement
				$sql = '';
				break;

			case 'delete':
				$sql = "DELETE FROM {$table}";
				break;

			// Get queries
			default:
				$fromString = $this->state->getFromString();
				$selectString = $this->state->getSelectString();

				$sql = "SELECT * \nFROM {$fromString}";

				// Set the select string
				if ( ! empty($selectString))
				{
					// Replace the star with the selected fields
					$sql = str_replace('*', $selectString, $sql);
				}
				break;
		}

		return $sql;
	}
protected function _compileType(string $type='', string $table=''): string
	{
		$setArrayKeys = $this->state->getSetArrayKeys();
		switch($type)
		{
			case 'insert':
				$paramCount = count($setArrayKeys);
				$params = array_fill(0, $paramCount, '?');
				$sql = "INSERT INTO {$table} ("
					. implode(',', $setArrayKeys)
					. ")\nVALUES (".implode(',', $params).')';
				break;

			case 'update':
				$setString = $this->state->getSetString();
				$sql = "UPDATE {$table}\nSET {$setString}";
				break;

			case 'replace':
				// @TODO implement
				$sql = '';
				break;

			case 'delete':
				$sql = "DELETE FROM {$table}";
				break;

			// Get queries
			default:
				$fromString = $this->state->getFromString();
				$selectString = $this->state->getSelectString();

				$sql = "SELECT * \nFROM {$fromString}";

				// Set the select string
				if ( ! empty($selectString))
				{
					// Replace the star with the selected fields
					$sql = str_replace('*', $selectString, $sql);
				}
				break;
		}

		return $sql;
	}
protected function _compileType ( string $ type = '' , string $ table = '' ) : string { $ setArrayKeys = $ this -> state -> getSetArrayKeys ( ) ; switch ( $ type ) { case 'insert' : $ paramCount = count ( $ setArrayKeys ) ; $ params = array_fill ( 0 , $ paramCount , '?' ) ; $ sql = "INSERT INTO {$table} (" . implode ( ',' , $ setArrayKeys ) . ")\nVALUES (" . implode ( ',' , $ params ) . ')' ; break ; case 'update' : $ setString = $ this -> state -> getSetString ( ) ; $ sql = "UPDATE {$table}\nSET {$setString}" ; break ; case 'replace' : // @TODO implement $ sql = '' ; break ; case 'delete' : $ sql = "DELETE FROM {$table}" ; break ; // Get queries default : $ fromString = $ this -> state -> getFromString ( ) ; $ selectString = $ this -> state -> getSelectString ( ) ; $ sql = "SELECT * \nFROM {$fromString}" ; // Set the select string if ( ! empty ( $ selectString ) ) { // Replace the star with the selected fields $ sql = str_replace ( '*' , $ selectString , $ sql ) ; } break ; } return $ sql ; }
Sub-method for generating sql strings

@param string $type
@param string $table
@return string
Sub - method for generating sql strings