/** * Prepare belongs to constraint statement. * * @param TypeInterface $type * @param TriggerInterface $trigger * @return string */ public function prepareCreateTriggerStatement(TypeInterface $type, TriggerInterface $trigger) { if (strpos($trigger->getBody(), "\n") === false) { return rtrim('CREATE TRIGGER ' . $this->getConnection()->escapeFieldName($trigger->getName()) . ' ' . strtoupper($trigger->getTime()) . ' ' . strtoupper($trigger->getEvent()) . ' ON ' . $this->getConnection()->escapeTableName($type->getName()) . ' FOR EACH ROW ' . $trigger->getBody(), ';') . ';'; } else { $result = []; $result[] = 'CREATE TRIGGER ' . $this->getConnection()->escapeFieldName($trigger->getName()) . ' ' . strtoupper($trigger->getTime()) . ' ' . strtoupper($trigger->getEvent()) . ' ON ' . $this->getConnection()->escapeTableName($type->getName()); $result[] = 'FOR EACH ROW BEGIN'; $result[] = $trigger->getBody(); $result[] = 'END;'; return $this->wrapDelimiter(implode("\n", $result)); } }