Code snippets for symfony 1.x


Refine Tags

Snippets tagged "random"

Fetch a Random Record with Doctrine

To fetch a random user:

$userCount = Doctrine::getTable('User')->count();
$user = Doctrine::getTable('User')
  ->offset(rand(0, $userCount - 1))
by ericfreese on 2009-11-16, tagged doctrine  random  record 

Little trick to randomize results

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);

obvious? sorry, seen someone asking on IRC once :D

by Romain Dorgueil on 2006-05-29, tagged column  criteria  database  order  propel  random