<?php
$d = new \PDO('mysql:host=mysql;dbname=test', 'username', 'password');
$sql = <<<SQL
CREATE TRIGGER before_update_elem BEFORE UPDATE ON dc_operations FOR EACH ROW BEGIN
CASE
WHEN (...) THEN
INSERT INTO ...
WHEN (...) THEN
INSERT INTO ...
ELSE BEGIN END;
END CASE;
END
SQL;
$d->exec($sql);