src/Drivers/AbstractUtil.php
public function createTable($name, $fields, array $constraints=[], $ifNotExists=TRUE)
	{
		$existsStr = $ifNotExists ? ' IF NOT EXISTS ' : ' ';

		// Reorganize into an array indexed with column information
		// Eg $columnArray[$colname] = array(
		// 		'type' => ...,
		// 		'constraint' => ...,
		// 		'index' => ...,
		// )
		$columnArray = \arrayZipper([
			'type' => $fields,
			'constraint' => $constraints
		]);

		// Join column definitions together
		$columns = [];
		foreach($columnArray as $n => $props)
		{
			$str = $this->getDriver()->quoteIdent($n);
			$str .= isset($props['type']) ? " {$props['type']}" : "";
			$str .= isset($props['constraint']) ? " {$props['constraint']}" : "";

			$columns[] = $str;
		}

		// Generate the sql for the creation of the table
		$sql = 'CREATE TABLE'.$existsStr.$this->getDriver()->quoteTable($name).' (';
		$sql .= implode(', ', $columns);
		$sql .= ')';

		return $sql;
	}
public function createTable($name, $fields, array $constraints=[], $ifNotExists=TRUE)
	{
		$existsStr = $ifNotExists ? ' IF NOT EXISTS ' : ' ';

		// Reorganize into an array indexed with column information
		// Eg $columnArray[$colname] = array(
		// 		'type' => ...,
		// 		'constraint' => ...,
		// 		'index' => ...,
		// )
		$columnArray = \arrayZipper([
			'type' => $fields,
			'constraint' => $constraints
		]);

		// Join column definitions together
		$columns = [];
		foreach($columnArray as $n => $props)
		{
			$str = $this->getDriver()->quoteIdent($n);
			$str .= isset($props['type']) ? " {$props['type']}" : "";
			$str .= isset($props['constraint']) ? " {$props['constraint']}" : "";

			$columns[] = $str;
		}

		// Generate the sql for the creation of the table
		$sql = 'CREATE TABLE'.$existsStr.$this->getDriver()->quoteTable($name).' (';
		$sql .= implode(', ', $columns);
		$sql .= ')';

		return $sql;
	}
public function createTable ( $ name , $ fields , array $ constraints = [ ] , $ ifNotExists = TRUE ) { $ existsStr = $ ifNotExists ? ' IF NOT EXISTS ' : ' ' ; // Reorganize into an array indexed with column information // Eg $columnArray[$colname] = array( // 		'type' => ..., // 		'constraint' => ..., // 		'index' => ..., // ) $ columnArray = \ arrayZipper ( [ 'type' => $ fields , 'constraint' => $ constraints ] ) ; // Join column definitions together $ columns = [ ] ; foreach ( $ columnArray as $ n => $ props ) { $ str = $ this -> getDriver ( ) -> quoteIdent ( $ n ) ; $ str .= isset ( $ props [ 'type' ] ) ? " {$props['type']}" : "" ; $ str .= isset ( $ props [ 'constraint' ] ) ? " {$props['constraint']}" : "" ; $ columns [ ] = $ str ; } // Generate the sql for the creation of the table $ sql = 'CREATE TABLE' . $ existsStr . $ this -> getDriver ( ) -> quoteTable ( $ name ) . ' (' ; $ sql .= implode ( ', ' , $ columns ) ; $ sql .= ')' ; return $ sql ; }
Convenience public function to generate sql for creating a db table

@param string $name
@param array $fields
@param array $constraints
@param bool $ifNotExists
@return string
Convenience public function to generate sql for creating a db table