src/Squid/MySql/Impl/Command/CmdSelect.php
protected function generate() 
	{
		$command = 
			'SELECT ' . 
				($this->getPart(CmdSelect::PART_DISTINCT) ? 'DISTINCT ' : ''). 
				Assembly::appendDirectly(($this->getPart(CmdSelect::PART_COLUMNS) ?: array('*')), ',');
		
		$union = $this->getPart(CmdSelect::PART_UNION);
		$from = $this->getPart(CmdSelect::PART_FROM);
		
		if (!$from && !$union) 
		{
			return $command;
		}
		
		$lock = $this->getPart(CmdSelect::PART_LOCK);
		
		$command .=
			Assembly::append('FROM', $from, ' ') .
			Assembly::appendWhere($this->getPart(CmdSelect::PART_WHERE)) .
			Assembly::append('GROUP BY', $this->getPart(CmdSelect::PART_GROUP_BY)) . 
			($this->getPart(CmdSelect::PART_WITH_ROLL_UP) ? 'WITH ROLLUP ' : '') . 
			Assembly::append('HAVING', $this->getPart(CmdSelect::PART_HAVING)) . 
			Assembly::append('ORDER BY', $this->getPart(CmdSelect::PART_ORDER_BY)) .
			Assembly::append('LIMIT', $this->getPart(CmdSelect::PART_LIMIT));
		
		if ($union) 
		{
			$union = implode(' ', $union);
			$command = "($command) $union";
		}
		
		return $command . ($lock ? "$lock " : '');
	}
protected function generate() 
	{
		$command = 
			'SELECT ' . 
				($this->getPart(CmdSelect::PART_DISTINCT) ? 'DISTINCT ' : ''). 
				Assembly::appendDirectly(($this->getPart(CmdSelect::PART_COLUMNS) ?: array('*')), ',');
		
		$union = $this->getPart(CmdSelect::PART_UNION);
		$from = $this->getPart(CmdSelect::PART_FROM);
		
		if (!$from && !$union) 
		{
			return $command;
		}
		
		$lock = $this->getPart(CmdSelect::PART_LOCK);
		
		$command .=
			Assembly::append('FROM', $from, ' ') .
			Assembly::appendWhere($this->getPart(CmdSelect::PART_WHERE)) .
			Assembly::append('GROUP BY', $this->getPart(CmdSelect::PART_GROUP_BY)) . 
			($this->getPart(CmdSelect::PART_WITH_ROLL_UP) ? 'WITH ROLLUP ' : '') . 
			Assembly::append('HAVING', $this->getPart(CmdSelect::PART_HAVING)) . 
			Assembly::append('ORDER BY', $this->getPart(CmdSelect::PART_ORDER_BY)) .
			Assembly::append('LIMIT', $this->getPart(CmdSelect::PART_LIMIT));
		
		if ($union) 
		{
			$union = implode(' ', $union);
			$command = "($command) $union";
		}
		
		return $command . ($lock ? "$lock " : '');
	}
Combine all the parts into one sql.
@return string Sql query