* @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 * @link http://orange-management.com */ declare(strict_types=1); namespace phpOMS\DataStorage\Database\Query\Grammar; use phpOMS\DataStorage\Database\Query\Builder; /** * Grammar class. * * @category Framework * @package phpOMS\DataStorage\Database\Query\Grammar * @author OMS Development Team * @license OMS License 1.0 * @link http://orange-management.com * @since 1.0.0 */ class SqliteGrammar extends Grammar { /** * System identifier. * * @var string * @since 1.0.0 */ public $systemIdentifier = '`'; /** * Compile random. * * @param Builder $query Builder * @param array $columns Columns * * @return string * * @since 1.0.0 */ protected function compileRandom(Builder $query, array $columns) : string { $expression = $this->expressionizeTableColumn($columns, $query->getPrefix()); if ($expression === '') { $expression = '*'; } return 'SELECT ' . $expression . ' ' . $this->compileFrom($query, $query->from) . ' ORDER BY RANDOM() ' . $this->compileLimit($query, $query->limit); } }