shimmie2
shimmie2 copied to clipboard
Optimizing random
Using RAND() function to make shuffle work faster. I don't know what other databases are used and if they also have RAND().
I don't know what other databases are used and if they also have RAND().
As listed on the Install documentation, Shimmie currently supports PostgreSQL 14+ / MySQL 8.0+ / SQLite 3.37+.
MySQL has RAND(). PostgreSQL and SQLite don't have RAND(), instead they have RANDOM(). The code will need to check which type of database it is to give the correct random function name. Something like:
if ($database->get_driver_id() == DatabaseDriverID::MYSQL) {
$order = "RAND()";
} else {
$order = "RANDOM()";
}
I also noticed all the formatting and static analysis tests are failing too. Use these tools to test your code :)