$query = Doctrine_Query::create() ->select('u.username') ->from('User u') ->where('u.id = ?', 5); $sql = $query->getSql();
$query = Doctrine_Query::create() ->from('User u') ->leftJoin('u.Profile p') ->where('p.age > ?', 18); $sql = $query->getSql();In this example, the query object retrieves all user objects with a related profile object that has an age greater than 18. The getSql function retrieves the SQL query statement that is generated by this query object. The Doctrine_Query package library is included in the Doctrine project which is a PHP ORM tool.