function _DatabaseHandler::request_new_degree_id

4.x _DatabaseHandler.php _DatabaseHandler::request_new_degree_id()
5.x _DatabaseHandler.php _DatabaseHandler::request_new_degree_id()

File

classes/_DatabaseHandler.php, line 821

Class

_DatabaseHandler

Code

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

  for ($t = 0; $t < 100; $t++) 
   {
    $id = mt_rand(1, 9999999);
    // Check for collisions...
    $res4 = $this->db_query("SELECT * FROM draft_degrees
							WHERE `degree_id`='$id' limit 1");
    if ($this->db_num_rows($res4) == 0) 
     { // Was not in the table already, so use it!
      return $id;
    }
  }

  return false;

}