I would like to implement paging for a random set
Select * from Animals ORDER BY random(SEED) LIMIT 100 OFFSET 50
I tried to set int to
I don't know if you're wanting a PHP and iOS solution, but if you are only interested in iOS and dont care much about using the built-in sqlite random() function, you could declare a custom function to use in your queries, one that does take a seed parameter.
sqlite3_create_function(database, "CUSTOM_RANDOM", 1, SQLITE_UTF8, NULL, &CustomRandomSQLite, NULL, NULL);
.
void CustomRandomSQLite(sqlite3_context* context, int argc, sqlite3_value** argv)
{
if(argc == 1 && sqlite3_value_type(argv[0]) == SQLITE_INTEGER)
{
const int seed = sqlite3_value_int(argv[0]);
const int result = ...;
sqlite3_result_int(context, result);
}
else
{
sqlite3_result_error(context, "Invalid", 0);
}
}
.
Select * from Animals ORDER BY CUSTOM_RANDOM(SEED) LIMIT 100 OFFSET 50