![]() |
|
Snippets |
|
To fetch a random user:
$userCount = Doctrine::getTable('User')->count(); $user = Doctrine::getTable('User') ->createQuery() ->limit(1) ->offset(rand(0, $userCount - 1)) ->fetchOne();
More a PHP trick than symfony's one, but as you can't with propel randomize order of results, just do:
$c = new Criteria() ... fill your criteria there ... $result = MyTablePeer::doSelect($c); shuffle($result);
obvious? sorry, seen someone asking on IRC once :D