function DatabaseHandler::request_new_course_id
Search API
7.x DatabaseHandler.php | DatabaseHandler::request_new_course_id() |
6.x DatabaseHandler.php | DatabaseHandler::request_new_course_id() |
File
- classes/
DatabaseHandler.php, line 405
Class
Code
function request_new_course_id()
{
// Return a valid new course_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_courses
WHERE course_id = $id LIMIT 1");
if ($this->db_num_rows($res4) == 0)
{ // Was not in the table already, so use it!
return $id;
}
}
return false;
}