lib/Doctrine/DBAL/Query/QueryBuilder.php
public function getSQL()
    {
        if ($this->sql !== null && $this->state === self::STATE_CLEAN) {
            return $this->sql;
        }

        switch ($this->type) {
            case self::INSERT:
                $sql = $this->getSQLForInsert();
                break;
            case self::DELETE:
                $sql = $this->getSQLForDelete();
                break;

            case self::UPDATE:
                $sql = $this->getSQLForUpdate();
                break;

            case self::SELECT:
            default:
                $sql = $this->getSQLForSelect();
                break;
        }

        $this->state = self::STATE_CLEAN;
        $this->sql   = $sql;

        return $sql;
    }
public function getSQL()
    {
        if ($this->sql !== null && $this->state === self::STATE_CLEAN) {
            return $this->sql;
        }

        switch ($this->type) {
            case self::INSERT:
                $sql = $this->getSQLForInsert();
                break;
            case self::DELETE:
                $sql = $this->getSQLForDelete();
                break;

            case self::UPDATE:
                $sql = $this->getSQLForUpdate();
                break;

            case self::SELECT:
            default:
                $sql = $this->getSQLForSelect();
                break;
        }

        $this->state = self::STATE_CLEAN;
        $this->sql   = $sql;

        return $sql;
    }
public function getSQL ( ) { if ( $ this -> sql !== null && $ this -> state === self :: STATE_CLEAN ) { return $ this -> sql ; } switch ( $ this -> type ) { case self :: INSERT : $ sql = $ this -> getSQLForInsert ( ) ; break ; case self :: DELETE : $ sql = $ this -> getSQLForDelete ( ) ; break ; case self :: UPDATE : $ sql = $ this -> getSQLForUpdate ( ) ; break ; case self :: SELECT : default : $ sql = $ this -> getSQLForSelect ( ) ; break ; } $ this -> state = self :: STATE_CLEAN ; $ this -> sql = $ sql ; return $ sql ; }
Gets the complete SQL string formed by the current specifications of this QueryBuilder.

<code>
$qb = $em->createQueryBuilder()
->select('u')
->from('User', 'u')
echo $qb->getSQL(); // SELECT u FROM User u
</code>

@return string The SQL query string.
Gets the complete SQL string formed by the current specifications of this QueryBuilder .