Yes, Jean Valjean is right.
My friend, if your raw SQL is working well then why don't you use raw SQL Query.
Let me help you in writing this.
First you need PDO (PHP data object), which is will be database handler for your raw query.
$pdo = Doctrine_Manager::getInstance()->getCurrentConnection()->getDbh();
then prepare the statement and execute it:
$query = "SELECT Sum(s) AS s
FROM (SELECT DISTINCT oder.id AS m,
o_t.restaurants_id,
o_t.value AS s
FROM orders AS oder
INNER JOIN order_total AS o_t
ON oder.id = o_t.orders_id
INNER JOIN order_status AS o_s
ON oder.id = o_s.orders_id
WHERE o_s.status = 1
AND o_t.code = 'total') a";
$stmt = $pdo->prepare($query);
$stmt->execute();
$results = $stmt->fetchAll();
You can also pass parameters like follows:
$query = "SELECT * FROM table WHERE param1 = :param1 AND param2 = :param2";
$stmt = $pdo->prepare($query);
$params = array(
"param1" => "value1",
"param2" => "value2"
);
$stmt->execute($params);
$results = $stmt->fetchAll();