@@ 84-103 (lines=20) @@ | ||
81 | $this->connection->exec($sql); |
|
82 | } |
|
83 | ||
84 | public function createDeleteTrigger(Table $table) |
|
85 | { |
|
86 | $triggerName = sprintf('TRG_%s_ONDELETE', $table->getName()); |
|
87 | ||
88 | $sql = sprintf(' |
|
89 | DROP TRIGGER IF EXISTS %s; |
|
90 | ||
91 | CREATE TRIGGER %s BEFORE DELETE ON `%s` |
|
92 | FOR EACH ROW |
|
93 | BEGIN |
|
94 | INSERT INTO local_delete VALUES (%s, OLD.uid, OLD.id); |
|
95 | DELETE FROM local_insert WHERE table_name = %s AND uid = OLD.uid; |
|
96 | DELETE FROM local_update WHERE table_name = %s AND uid = OLD.uid; |
|
97 | END; |
|
98 | ||
99 | ', $triggerName, $triggerName, $table->getName(), $this->connection->quote($table->getName()), $this->connection->quote($table->getName()), $this->connection->quote($table->getName())); |
|
100 | ||
101 | $this->connection->exec($sql); |
|
102 | } |
|
103 | ||
104 | public function createUpdateTrigger(Table $table) |
|
105 | { |
|
106 | $triggerName = sprintf('TRG_%s_ONUPDATE', $table->getName()); |
|
@@ 62-83 (lines=22) @@ | ||
59 | $dbalTableDiffService->createOrUpdateTable($localDelete); |
|
60 | } |
|
61 | ||
62 | public function createInsertTrigger(Table $table) |
|
63 | { |
|
64 | $triggerName = sprintf('TRG_%s_ONINSERT', $table->getName()); |
|
65 | ||
66 | $sql = sprintf(' |
|
67 | DROP TRIGGER IF EXISTS %s; |
|
68 | ||
69 | CREATE TRIGGER %s AFTER INSERT ON `%s` |
|
70 | FOR EACH ROW |
|
71 | BEGIN |
|
72 | IF (NEW.lastActivityTime IS NULL) THEN |
|
73 | INSERT INTO local_insert VALUES (%s, NEW.uid); |
|
74 | DELETE FROM local_delete WHERE table_name = %s AND uid = NEW.uid; |
|
75 | DELETE FROM local_update WHERE table_name = %s AND uid = NEW.uid; |
|
76 | END IF; |
|
77 | END; |
|
78 | ||
79 | ', $triggerName, $triggerName, $table->getName(), $this->connection->quote($table->getName()), $this->connection->quote($table->getName()), $this->connection->quote($table->getName())); |
|
80 | ||
81 | $this->connection->exec($sql); |
|
82 | } |
|
83 | ||
84 | public function createDeleteTrigger(Table $table) |
|
85 | { |
|
86 | $triggerName = sprintf('TRG_%s_ONDELETE', $table->getName()); |