Does RAND() work with PODS?
I'm needing a sanity check :) I've got some PODS named profile and I want to get the list of people whose profile says that they're from Washington, but display it in a random order. Here's my code. Instead of displaying the items in a random order, it displays them in the same order (the order that they were added to the system, it appears) every time. Is there anything that stands out incorrectly to ya'll?? Thank you!
$directory = new Pod('profile');
$params = array('RAND()', -1, "t.state='Washington'");
$directory->findRecords($params);
<?php if( $total_members>0 ) : ?>
<?php while ( $directory->fetchRecord() ) : ?>
/* code to display name etc.*/
<?php endwhile ?>
<?php endif ?>
2 Answers
Almost there, you have two options for findRecords:
$directory->findRecords('RAND()', -1, "t.state='Washington'");
Or
$params = array('orderby'=>'RAND()', 'limit=>-1, 'where'=>"t.state='Washington'");
$directory->findRecords($params);
Yowzahs sc0ttkclark - you solved my problem!!!!! Thank you so much - I was beating my head against the table. Have a great day and thank you again!!!! I made a little donation to PODS Cms in your honor just now :) –
kirstenbrooks
Dec 3 '10 at 8:23
Hi Scott
Can I just check that the second example is correct?
Shouldn't the limit syntax be <pre>'limit'=>-1</pre> ?
Cheers –
thehobbo
Feb 5 at 6:07
enter at least 15 characters
.
edited Dec 3 '10 at 8:24


