final class CreateEvent
    implements Statement
    uses Snapshot
Public API: explicitly declared with @visibility public.

CREATE EVENT: a statement the event scheduler runs once or repeatedly.

The statement is structured as a request: it declares nothing to a context. The facts follow MYSQL-EVENT-001. Source: https://dev.mysql.com/doc/refman/8.4/en/create-event.html.

Reading an event definitiondoctest
$create = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("CREATE EVENT e ON SCHEDULE EVERY 1 DAY ON COMPLETION PRESERVE DISABLE COMMENT 'nightly' DO DELETE FROM log");
    [$create->statement->completion, $create->statement->status, $create->statement->comment->value] // => [\SqlSemantics\Platform\MySql\Statement\Routine\Event\Completion::Preserve, \SqlSemantics\Platform\MySql\Statement\Routine\Event\EventStatus::Disable, 'nightly']

Properties§

public Schedule $schedule
public Completion|null $completion = null
public EventStatus|null $status = null
public Text|null $comment = null
public Account|null $definer = null
public bool $ifNotExists = false

Methods§

public function __construct(
    public QualifiedName $name,
    public Schedule $schedule,
    Node $body,
    public Completion|null $completion = null,
    public EventStatus|null $status = null,
    public Text|null $comment = null,
    public Account|null $definer = null,
    public bool $ifNotExists = false,
)

Parameters

$nameQualifiedNameThe event name with its optional database
$scheduleScheduleWhen the event runs
$bodyNodeThe statement the event runs: a program statement or an SQL statement
$completionCompletion|nullThe ON COMPLETION clause, when written
$statusEventStatus|nullThe status clause, when written
$commentText|nullThe COMMENT clause, when written
$definerAccount|nullThe DEFINER clause, when written
$ifNotExistsboolWhether IF NOT EXISTS is written

Throws

InvalidConstruction When the body is of another class
Calls 3
public function deriveStatement(Derivation $derivation): void

Derives the schedule and the body.

Parameters

$derivationDerivation
Calls 2
public function render(Output $out): void

Writes the statement.

Parameters

$outOutput
Calls 5

Test cases 18§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 4
Other tests reaching this symbol 14

Relations§

Instantiated in 1
Type checks 1
Type declarations 1