public function toSQL(Parameters $params, bool $inner_clause)
    {
        $drv = $params->getDriver();
        // First get the source tables: FROM and JOIN clauses
        $source = array();

        if ($table = $this->getTable())
            $source[] = "FROM " . $drv->toSQL($params, $table);

        foreach ($this->getJoins() as $join)
            $source[] = $drv->toSQL($params, $join);

        // Now build the start of the query, all tables should be known
        $parts = array();

        $parts[] = "SELECT";
        $fields = $this->getFields();
        if (!empty($fields))
        {
            $field_parts = array();
            foreach ($fields as $field)
                $field_parts[] = $drv->toSQL($params, $field);
            $parts[] = implode(", ", $field_parts);
        }
        else
            $parts[] = "*";

        // Add the source tables and joins to the query
        foreach ($source as $part)
            $parts[] = $part;

        if ($where = $this->getWhere())
            $parts[] = $drv->toSQL($params, $where);

        if ($union = $this->getUnion())
            $parts[] = $drv->toSQL($params, $union);
        
        if ($order = $this->getOrder())
            $parts[] = $drv->toSQL($params, $order);

        if ($limit = $this->getLimit())
            $parts[] = $drv->toSQL($params, $limit);
        
        if ($offset = $this->getOffset())
            $parts[] = $drv->toSQL($params, $offset);
        
        return implode(" ", $parts);
    }
public function toSQL(Parameters $params, bool $inner_clause)
    {
        $drv = $params->getDriver();
        // First get the source tables: FROM and JOIN clauses
        $source = array();

        if ($table = $this->getTable())
            $source[] = "FROM " . $drv->toSQL($params, $table);

        foreach ($this->getJoins() as $join)
            $source[] = $drv->toSQL($params, $join);

        // Now build the start of the query, all tables should be known
        $parts = array();

        $parts[] = "SELECT";
        $fields = $this->getFields();
        if (!empty($fields))
        {
            $field_parts = array();
            foreach ($fields as $field)
                $field_parts[] = $drv->toSQL($params, $field);
            $parts[] = implode(", ", $field_parts);
        }
        else
            $parts[] = "*";

        // Add the source tables and joins to the query
        foreach ($source as $part)
            $parts[] = $part;

        if ($where = $this->getWhere())
            $parts[] = $drv->toSQL($params, $where);

        if ($union = $this->getUnion())
            $parts[] = $drv->toSQL($params, $union);
        
        if ($order = $this->getOrder())
            $parts[] = $drv->toSQL($params, $order);

        if ($limit = $this->getLimit())
            $parts[] = $drv->toSQL($params, $limit);
        
        if ($offset = $this->getOffset())
            $parts[] = $drv->toSQL($params, $offset);
        
        return implode(" ", $parts);
    }
public function toSQL ( Parameters $ params , bool $ inner_clause ) { $ drv = $ params -> getDriver ( ) ; // First get the source tables: FROM and JOIN clauses $ source = array ( ) ; if ( $ table = $ this -> getTable ( ) ) $ source [ ] = "FROM " . $ drv -> toSQL ( $ params , $ table ) ; foreach ( $ this -> getJoins ( ) as $ join ) $ source [ ] = $ drv -> toSQL ( $ params , $ join ) ; // Now build the start of the query, all tables should be known $ parts = array ( ) ; $ parts [ ] = "SELECT" ; $ fields = $ this -> getFields ( ) ; if ( ! empty ( $ fields ) ) { $ field_parts = array ( ) ; foreach ( $ fields as $ field ) $ field_parts [ ] = $ drv -> toSQL ( $ params , $ field ) ; $ parts [ ] = implode ( ", " , $ field_parts ) ; } else $ parts [ ] = "*" ; // Add the source tables and joins to the query foreach ( $ source as $ part ) $ parts [ ] = $ part ; if ( $ where = $ this -> getWhere ( ) ) $ parts [ ] = $ drv -> toSQL ( $ params , $ where ) ; if ( $ union = $ this -> getUnion ( ) ) $ parts [ ] = $ drv -> toSQL ( $ params , $ union ) ; if ( $ order = $ this -> getOrder ( ) ) $ parts [ ] = $ drv -> toSQL ( $ params , $ order ) ; if ( $ limit = $ this -> getLimit ( ) ) $ parts [ ] = $ drv -> toSQL ( $ params , $ limit ) ; if ( $ offset = $ this -> getOffset ( ) ) $ parts [ ] = $ drv -> toSQL ( $ params , $ offset ) ; return implode ( " " , $ parts ) ; }
Write a select query as SQL query syntax
@param Parameters $params The query parameters: tables and placeholder values
@param bool $inner_clause Unused
@return string The generated SQL
Write a select query as SQL query syntax