function DatabaseHandler::request_new_degree_id

7.x DatabaseHandler.php DatabaseHandler::request_new_degree_id()
6.x DatabaseHandler.php DatabaseHandler::request_new_degree_id()

File

classes/DatabaseHandler.php, line 948

Class

DatabaseHandler

Code

function request_new_degree_id() 
 {
  // Return a valid new id...

  for ($t = 0; $t < 1000; $t++) 
   {
    $id = mt_rand(1, 2147483640); // A few less than the max for a signed int in mysql.
    // Check for collisions...
    $res4 = $this->db_query("SELECT * FROM draft_degrees
              WHERE `degree_id`='?' limit 1", $id);
    if ($this->db_num_rows($res4) == 0) 
     { // Was not in the table already, so use it!
      return $id;
    }
  }

  return false;

}