How do I do this:
SELECT t.id FROM table t JOIN (SELECT(FLOOR(max(id) * rand())) AS maxid FROM table) AS tt ON t.id >= tt.maxid LIMIT 1
$connection = Doctrine_Manager::getConnection()->getDbh(); $result = $connection->query('SELECT ...');