sajad torkamani

Assuming you have a QueryBuilder object, you can do:

$queryBuilder->getQuery()->getSQL()