src/Common/DebugSql.php
public static function getFullSQL($query)
    {
        $sql = $query->getSql();
        $paramsList = self::getListParamsByDql($query->getDql());
        $paramsArr = self::getParamsArray($query->getParameters());
        $fullSql = '';
        for ($i = 0; $i < strlen($sql); $i++) {
            if ($sql[$i] == '?') {
                $nameParam = array_shift($paramsList);

                if (!isset($paramsArr[$nameParam])) {
                    $fullSql .= ':' . $nameParam;
                } elseif (is_string($paramsArr[$nameParam])) {
                    $fullSql .= '"' . addslashes($paramsArr[$nameParam]) . '"';
                } elseif (is_array($paramsArr[$nameParam])) {
                    $sqlArr = '';
                    foreach ($paramsArr[$nameParam] as $var) {
                        if (!empty($sqlArr))
                            $sqlArr .= ',';

                        if (is_string($var)) {
                            $sqlArr .= '"' . addslashes($var) . '"';
                        } else
                            $sqlArr .= $var;
                    }
                    $fullSql .= $sqlArr;
                } elseif (is_object($paramsArr[$nameParam])) {
                    switch (get_class($paramsArr[$nameParam])) {
                        case 'DateTime':
                            $fullSql .= '\'' . $paramsArr[$nameParam]->format('Y-m-d H:i:s') . '\'';
                            break;
                        default:
                            $fullSql .= $paramsArr[$nameParam]->getId();
                    }

                } else
                    $fullSql .= $paramsArr[$nameParam];

            } else {
                $fullSql .= $sql[$i];
            }
        }
        return $fullSql;
    }
public static function getFullSQL($query)
    {
        $sql = $query->getSql();
        $paramsList = self::getListParamsByDql($query->getDql());
        $paramsArr = self::getParamsArray($query->getParameters());
        $fullSql = '';
        for ($i = 0; $i < strlen($sql); $i++) {
            if ($sql[$i] == '?') {
                $nameParam = array_shift($paramsList);

                if (!isset($paramsArr[$nameParam])) {
                    $fullSql .= ':' . $nameParam;
                } elseif (is_string($paramsArr[$nameParam])) {
                    $fullSql .= '"' . addslashes($paramsArr[$nameParam]) . '"';
                } elseif (is_array($paramsArr[$nameParam])) {
                    $sqlArr = '';
                    foreach ($paramsArr[$nameParam] as $var) {
                        if (!empty($sqlArr))
                            $sqlArr .= ',';

                        if (is_string($var)) {
                            $sqlArr .= '"' . addslashes($var) . '"';
                        } else
                            $sqlArr .= $var;
                    }
                    $fullSql .= $sqlArr;
                } elseif (is_object($paramsArr[$nameParam])) {
                    switch (get_class($paramsArr[$nameParam])) {
                        case 'DateTime':
                            $fullSql .= '\'' . $paramsArr[$nameParam]->format('Y-m-d H:i:s') . '\'';
                            break;
                        default:
                            $fullSql .= $paramsArr[$nameParam]->getId();
                    }

                } else
                    $fullSql .= $paramsArr[$nameParam];

            } else {
                $fullSql .= $sql[$i];
            }
        }
        return $fullSql;
    }
public static function getFullSQL ( $ query ) { $ sql = $ query -> getSql ( ) ; $ paramsList = self :: getListParamsByDql ( $ query -> getDql ( ) ) ; $ paramsArr = self :: getParamsArray ( $ query -> getParameters ( ) ) ; $ fullSql = '' ; for ( $ i = 0 ; $ i < strlen ( $ sql ) ; $ i ++ ) { if ( $ sql [ $ i ] == '?' ) { $ nameParam = array_shift ( $ paramsList ) ; if ( ! isset ( $ paramsArr [ $ nameParam ] ) ) { $ fullSql .= ':' . $ nameParam ; } elseif ( is_string ( $ paramsArr [ $ nameParam ] ) ) { $ fullSql .= '"' . addslashes ( $ paramsArr [ $ nameParam ] ) . '"' ; } elseif ( is_array ( $ paramsArr [ $ nameParam ] ) ) { $ sqlArr = '' ; foreach ( $ paramsArr [ $ nameParam ] as $ var ) { if ( ! empty ( $ sqlArr ) ) $ sqlArr .= ',' ; if ( is_string ( $ var ) ) { $ sqlArr .= '"' . addslashes ( $ var ) . '"' ; } else $ sqlArr .= $ var ; } $ fullSql .= $ sqlArr ; } elseif ( is_object ( $ paramsArr [ $ nameParam ] ) ) { switch ( get_class ( $ paramsArr [ $ nameParam ] ) ) { case 'DateTime' : $ fullSql .= '\'' . $ paramsArr [ $ nameParam ] -> format ( 'Y-m-d H:i:s' ) . '\'' ; break ; default : $ fullSql .= $ paramsArr [ $ nameParam ] -> getId ( ) ; } } else $ fullSql .= $ paramsArr [ $ nameParam ] ; } else { $ fullSql .= $ sql [ $ i ] ; } } return $ fullSql ; }
Get SQL from query

@param \Doctrine\ORM\Query $query
@return string
Get SQL from query