Does RAND() work with PODS?

0

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 ?>

asked Dec 3 '10 at 3:25

kirstenbrooks

1

add comment
enter at least 15 characters

2 Answers

2

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

answered Dec 3 '10 at 8:22

sc0ttkclark

2936

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
add comment
enter at least 15 characters
0

.

answered Dec 3 '10 at 2:26

kirstenbrooks

1

edited Dec 3 '10 at 8:24

add comment
enter at least 15 characters