Exemplo n.º 1
0
    /**
     * return the statement in string format
     *
     * @return string
     */
    public function toString()
    {
        $result = 'SELECT ';
        $columnNames = $this->_getColumnNames();
        if (empty($columnNames) === true) {
            $result .= '*';
        } else {
            $result .= implode(', ', $columnNames);
        }
        $result .= ' FROM ';
        $result .= $this->table->getName();
        if (isset($this->where) === true) {
            $result .= ' WHERE ';
            $result .= $this->where->toString();
        }
        if (isset($this->order) === true) {
            $result .= ' ORDER BY ';
            $result .= $this->order->toString();
        }

        if (isset($this->limit) === true) {
            $result .= ' LIMIT ';
            $result .= $this->limit->toString();
        }

        return $result;
    }