classInterval
final class Interval
implements Node
uses Snapshot
Public API: explicitly declared with
@visibility public.A temporal interval: INTERVAL quantity unit, the operand of interval arithmetic and of DATE_ADD and DATE_SUB.
An interval is not a value of its own; the expression that holds it derives the quantity. The quantity is enclosed between INTERVAL and the unit, so it may be any expression. Source: https://dev.mysql.com/doc/refman/8.4/en/expressions.html#temporal-intervals.
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t WHERE a + INTERVAL 2 DAY_HOUR');
[$query->statement->where->interval->quantity->text, $query->statement->where->interval->unit->value] // => ['2', 'DAY_HOUR']Properties§
public Scalar $quantitypublic IntervalUnit $unitMethods§
public function __construct(public Scalar $quantity, public IntervalUnit $unit)Parameters
$quantity | Scalar | The number of units, or the formatted string of a compound unit |
$unit | IntervalUnit | The unit |
public function render(Output $out): voidWrites INTERVAL, the quantity and the unit keyword.
Parameters
$out | Output |
Test cases 1
Calls 1
- method-call Output::keyword() line 43
Test cases 10§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
Other tests reaching this symbol 9
FullTextSearchTest::testASearchStringThatTakesTheBooleanModeIsRejectedcallsArithmeticTest::testARightOperandStartingWithALeadingIntervalIsRejectedcallsIntervalAdditionTest::testAConjunctionOperandIsRejectedcallsIntervalAdditionTest::testDeriveScalarMakesADateTimeForATimeUnitcallsIntervalAdditionTest::testRenderLetsTheOperandExtendOverAComparisoncallsIntervalArithmeticTest::testABitOperandIsRejectedcallsIntervalArithmeticTest::testAMultiplicativeOperandIsAcceptedcallsIntervalArithmeticTest::testDeriveScalarKeepsADateForADateUnitcallsIntervalArithmeticTest::testRenderWritesTheSignBeforeTheIntervalcalls
Relations§
Instantiated in 1
Type declarations 3
- type SqlSemantics\Platform\MySql\Lowering\Expression\ExpressionRules packages/sql-semantics-mysql/src/Lowering/Expression/ExpressionRules.php:94
- type SqlSemantics\Platform\MySql\Statement\Expression\Operator\IntervalAddition packages/sql-semantics-mysql/src/Statement/Expression/Operator/IntervalAddition.php:45
- type SqlSemantics\Platform\MySql\Statement\Expression\Operator\IntervalArithmetic packages/sql-semantics-mysql/src/Statement/Expression/Operator/IntervalArithmetic.php:45