The createTrigger statement stops execution when there is a hyphen (-) in the table name. This causes the code to fail when attempting to execute CREATE TRIGGER statements for tables with hyphenated names.
Proposed Solution:
To resolve this issue, we can modify the code to enclose the table name in backticks (`) in the CREATE TRIGGER statement. This will ensure that table names containing hyphens are properly handled.
Affected Code:
public function createTriggers(): void {
$stmts = "";
foreach ($this->getAllTablesExceptPhinxlogsAndCollector(true) as $table) {
$stmts .= "CREATE TRIGGER {$this->getTriggerName($table)} AFTER INSERT ON `{$table}`";
// Add trigger definition...
}
}
Issue Description:
The
createTrigger
statement stops execution when there is a hyphen (-
) in the table name. This causes the code to fail when attempting to executeCREATE TRIGGER
statements for tables with hyphenated names.Proposed Solution:
To resolve this issue, we can modify the code to enclose the table name in backticks (
`
) in theCREATE TRIGGER
statement. This will ensure that table names containing hyphens are properly handled.Affected Code: