Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| OracleGrammar | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
| compileRandom | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Jingga |
| 4 | * |
| 5 | * PHP Version 8.1 |
| 6 | * |
| 7 | * @package phpOMS\DataStorage\Database\Query\Grammar |
| 8 | * @copyright Dennis Eichhorn |
| 9 | * @license OMS License 2.0 |
| 10 | * @version 1.0.0 |
| 11 | * @link https://jingga.app |
| 12 | */ |
| 13 | declare(strict_types=1); |
| 14 | |
| 15 | namespace phpOMS\DataStorage\Database\Query\Grammar; |
| 16 | |
| 17 | use phpOMS\DataStorage\Database\Query\Builder; |
| 18 | |
| 19 | /** |
| 20 | * Grammar class. |
| 21 | * |
| 22 | * @package phpOMS\DataStorage\Database\Query\Grammar |
| 23 | * @license OMS License 2.0 |
| 24 | * @link https://jingga.app |
| 25 | * @since 1.0.0 |
| 26 | */ |
| 27 | class OracleGrammar extends Grammar |
| 28 | { |
| 29 | /** |
| 30 | * Compile random. |
| 31 | * |
| 32 | * @param Builder $query Builder |
| 33 | * @param array $columns Columns |
| 34 | * |
| 35 | * @return string |
| 36 | * |
| 37 | * @since 1.0.0 |
| 38 | */ |
| 39 | protected function compileRandom(Builder $query, array $columns) : string |
| 40 | { |
| 41 | $expression = $this->expressionizeTableColumn($columns); |
| 42 | |
| 43 | if ($expression === '') { |
| 44 | $expression = '*'; |
| 45 | } |
| 46 | |
| 47 | $query->limit = $query->limit ?? 1; |
| 48 | |
| 49 | return 'SELECT ' . $expression . ' FROM (SELECT ' . $expression . ' ' . $this->compileFrom($query, $query->from) . ' ORDER BY dbms_random.value) WHERE rownum >= 1 AND rownum <= ' . ($query->limit ?? 1); |
| 50 | } |
| 51 | } |