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, simon_w

get random object


Reply

4 Posts   2621 Views

Avatar
snaip

16 March 2009 at 1:28am (Last edited: 16 March 2009 2:37am), Community Member, 180 Posts

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

16 March 2009 at 11:21pm Community Member, 180 Posts

??

Avatar
snaip

17 March 2009 at 1:48am (Last edited: 17 March 2009 1:49am), Community Member, 180 Posts

AD 2)

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

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

Avatar
snaip

17 March 2009 at 2:11am Community Member, 180 Posts

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

ehhhh :/