public function compile_select( &$query )
	{
		$build = ( $query->distinct ? 'select distinct' : 'select' ).' ';

		if ( !empty( $query->fields ) )
		{
			foreach( $query->fields as $key => $field )
			{
				if ( !is_numeric( $key ) )
				{
					$build .= $this->escape( $key ).' as '.$this->escape( $field );
				}
				elseif ( is_array( $field ) )
				{
					$build .= $this->escape( $field[0] ).' as '.$this->escape( $field[1] );
				}
				else 
				{
					$build .= $this->escape( $field );
				}
				$build .= ', ';
			}

			$build = substr( $build, 0, -2 );
		}
		else 
		{
			$build .= '*';
		}

		// append the table
		$build .= ' from '.$this->escape_table( $query );

		// build the where stuff
		$build .= $this->compile_where( $query );
		$build .= $this->compile_group( $query );
		$build .= $this->compile_order( $query );
		$build .= $this->compile_limit_with_offset( $query );

		return $build;
	}