/**
  * Get the SQL for a select statement
  * @param zibo\library\database\manipulation\statement\manipulation\SelectStatement $statement
  * @return string SQL of the select statement
  */
 protected function parseSelectStatement(SelectStatement $statement)
 {
     $operator = $statement->getOperator();
     $sql = 'SELECT ';
     if ($statement->isDistinct()) {
         $sql .= 'DISTINCT ';
     }
     $fields = $statement->getFields();
     if (empty($fields)) {
         $sql . '*';
     } else {
         $sql .= $this->parseExpressionsForSelect($fields);
     }
     $tables = $statement->getTables();
     if ($tables) {
         $sql .= ' FROM ' . $this->parseTableExpressionsForFrom($tables);
     }
     $conditions = $statement->getConditions();
     if ($conditions) {
         $sql .= ' WHERE ' . $this->parseConditions($conditions, $operator, false);
     }
     $group = $statement->getGroupBy();
     if ($group) {
         $sql .= ' GROUP BY ' . $this->parseExpressions($group, ', ', true);
     }
     $having = $statement->getHaving();
     if ($having) {
         $sql .= ' HAVING ' . $this->parseConditions($having, $operator, true);
     }
     $order = $statement->getOrderBy();
     if ($order) {
         $sql .= ' ORDER BY ' . $this->parseExpressions($order, ', ', false);
     }
     $limit = $statement->getLimit();
     if ($limit) {
         $sql .= $this->parseLimitExpression($limit);
     }
     return $sql;
 }