This commit is contained in:
Benjamin Perche
2014-06-18 12:35:24 +02:00
parent 087f9e46a1
commit c5fa984e6e

View File

@@ -496,7 +496,7 @@ try {
echo "Creating orders\n"; echo "Creating orders\n";
for($i=0; $i < 50; ++$i) { for ($i=0; $i < 50; ++$i) {
$placedOrder = new \Thelia\Model\Order(); $placedOrder = new \Thelia\Model\Order();
@@ -902,11 +902,12 @@ function getRandomObject(\Propel\Runtime\ActiveQuery\ModelCriteria $query)
{ {
$max = $query->count(); $max = $query->count();
if($max === 0) { if ($max === 0) {
throw new Exception("There is no entry in ". get_class($query)); throw new Exception("There is no entry in ". get_class($query));
} }
$first_id = $query->findOne()->getId(); $first_id = $query->findOne()->getId();
$obj = $query->findPk(mt_rand($first_id, $first_id+$max-1)); $obj = $query->findPk(mt_rand($first_id, $first_id+$max-1));
return $obj; return $obj;
} }