lundi 28 septembre 2015

Php / sql Random users of Db

I get with Rand() random user out of the database. I am using php pdo so it looks like this: $db = DBWrapper::getInstance();

    /**
     * Random user 
     */
    $table = "staff";
    $columns    = array("id", "firstname", "lastname", "categorie_bit");
    $whereRand  = array('categorie_bit = :idRand');
    $valuesRand = array('idRand' => 00);
    $orderBy    = array('RAND()');

    $result_set  = $db->select($table, $columns, $whereRand, $valuesRand, $orderBy, 1);

    foreach($result_set as $result) { var_dump($result); }

This give me a Random user from the database.

Now I want to take randomly more users of the database but with the exception of not taken users I already took with Rand().

How to I accomplish that.




Aucun commentaire:

Enregistrer un commentaire