src/Mysqli/MysqliImporter.php
protected function getColumnSql(\SimpleXMLElement $field)
	{
		// TODO Incorporate into parent class and use $this.
		$blobs = array('text', 'smalltext', 'mediumtext', 'largetext');

		$fName    = (string) $field['Field'];
		$fType    = (string) $field['Type'];
		$fNull    = (string) $field['Null'];
		$fDefault = isset($field['Default']) ? (string) $field['Default'] : null;
		$fExtra   = (string) $field['Extra'];

		$sql = $this->db->quoteName($fName) . ' ' . $fType;

		if ($fNull === 'NO')
		{
			if ($fDefault === null || \in_array($fType, $blobs, true))
			{
				$sql .= ' NOT NULL';
			}
			else
			{
				// TODO Don't quote numeric values.
				$sql .= ' NOT NULL DEFAULT ' . $this->db->quote($fDefault);
			}
		}
		else
		{
			if ($fDefault === null)
			{
				$sql .= ' DEFAULT NULL';
			}
			else
			{
				// TODO Don't quote numeric values.
				$sql .= ' DEFAULT ' . $this->db->quote($fDefault);
			}
		}

		if ($fExtra)
		{
			$sql .= ' ' . strtoupper($fExtra);
		}

		return $sql;
	}
protected function getColumnSql(\SimpleXMLElement $field)
	{
		// TODO Incorporate into parent class and use $this.
		$blobs = array('text', 'smalltext', 'mediumtext', 'largetext');

		$fName    = (string) $field['Field'];
		$fType    = (string) $field['Type'];
		$fNull    = (string) $field['Null'];
		$fDefault = isset($field['Default']) ? (string) $field['Default'] : null;
		$fExtra   = (string) $field['Extra'];

		$sql = $this->db->quoteName($fName) . ' ' . $fType;

		if ($fNull === 'NO')
		{
			if ($fDefault === null || \in_array($fType, $blobs, true))
			{
				$sql .= ' NOT NULL';
			}
			else
			{
				// TODO Don't quote numeric values.
				$sql .= ' NOT NULL DEFAULT ' . $this->db->quote($fDefault);
			}
		}
		else
		{
			if ($fDefault === null)
			{
				$sql .= ' DEFAULT NULL';
			}
			else
			{
				// TODO Don't quote numeric values.
				$sql .= ' DEFAULT ' . $this->db->quote($fDefault);
			}
		}

		if ($fExtra)
		{
			$sql .= ' ' . strtoupper($fExtra);
		}

		return $sql;
	}
protected function getColumnSql ( \ SimpleXMLElement $ field ) { // TODO Incorporate into parent class and use $this. $ blobs = array ( 'text' , 'smalltext' , 'mediumtext' , 'largetext' ) ; $ fName = ( string ) $ field [ 'Field' ] ; $ fType = ( string ) $ field [ 'Type' ] ; $ fNull = ( string ) $ field [ 'Null' ] ; $ fDefault = isset ( $ field [ 'Default' ] ) ? ( string ) $ field [ 'Default' ] : null ; $ fExtra = ( string ) $ field [ 'Extra' ] ; $ sql = $ this -> db -> quoteName ( $ fName ) . ' ' . $ fType ; if ( $ fNull === 'NO' ) { if ( $ fDefault === null || \ in_array ( $ fType , $ blobs , true ) ) { $ sql .= ' NOT NULL' ; } else { // TODO Don't quote numeric values. $ sql .= ' NOT NULL DEFAULT ' . $ this -> db -> quote ( $ fDefault ) ; } } else { if ( $ fDefault === null ) { $ sql .= ' DEFAULT NULL' ; } else { // TODO Don't quote numeric values. $ sql .= ' DEFAULT ' . $ this -> db -> quote ( $ fDefault ) ; } } if ( $ fExtra ) { $ sql .= ' ' . strtoupper ( $ fExtra ) ; } return $ sql ; }
Get the SQL syntax for a single column that would be included in a table create or alter statement.

@param   \SimpleXMLElement  $field  The XML field definition.

@return  string

@since   1.0
Get the SQL syntax for a single column that would be included in a table create or alter statement .