Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo

get random object


Go to End
Reply


4 Posts   3051 Views

Avatar
snaip

Community Member, 180 Posts

16 March 2009 at 1:28am

Edited: 16/03/2009 2:37am

i need to get 4 random objects from database

    $Randomelements = DataObject::get(
      $callerClass = "PLWycieczkaPage",
      $filter = "Display = 'ON'",
      $sort = "",
      $join = "",
      $limit = 4 
    );
    return $Randomelements;

how to add RAND() to this code ?

sec question

how to execute in the same time two objects ?

    $Staticelements = DataObject::get(
      $callerClass = "ENWycieczkaPage",
      $filter = "Display = 'always'",
      $sort = "",
      $join = "",
      $limit = "" 
    );
    return $Staticelements;


    $Randomelements = DataObject::get(
      $callerClass = "PLWycieczkaPage",
      $filter = "Display = 'sometimes'",
      $sort = "",
      $join = "",
      $limit = 4 
    );
    return $Randomelements;

in this way only "return $Staticelement" works but it stop executing "return $Randomelements"

Avatar
snaip

Community Member, 180 Posts

16 March 2009 at 11:21pm

??

Avatar
snaip

Community Member, 180 Posts

17 March 2009 at 1:48am

Edited: 17/03/2009 1:49am

AD 2)

$doSet1->merge($doSet2);
return $doSet1;

what about RAND() function in DataObject::get ?

Avatar
snaip

Community Member, 180 Posts

17 March 2009 at 2:11am

$Randomelements = DataObject::get(
$callerClass = "PLWycieczkaPage",
$filter = "Display = 'sometimes'",
$sort = "RAND()",
$join = "",
$limit = 4
); 

ehhhh :/