You are here

protected function SeedCalculator::createInt in Views random seed 8

Helper function to create a seed based on db_type. MySQL can handle any integer in the RAND() function, Postgres needs an int between 0 and 1.

Parameters

int $time: The current timestamp.

string $db_type: The current database type (mysql(i) - pgsql)

Return value

int $seed timestamp or int between 0 and 1.

1 call to SeedCalculator::createInt()
SeedCalculator::generateSeed in src/SeedCalculator.php
Helper function to generate a seed

File

src/SeedCalculator.php, line 153

Class

SeedCalculator
Calculates seeds.

Namespace

Drupal\views_random_seed

Code

protected function createInt(int $time, string $db_type) {
  switch ($db_type) {
    case 'mysql':
    case 'mysqli':
    default:
      return $time;
    case 'pgsql':
      return $time / 10000000000;
  }
}