<?php
	
	$query =   "CREATE TRIGGER id_create BEFORE INSERT ON cdr FOR EACH ROW SET NEW.id = UUID();";
	$query =   "CREATE TRIGGER ecmcalls_assign AFTER INSERT ON cdr FOR EACH ROW INSERT INTO ecmcalls_beans (`id`, `ecmcall_id`, `bean_id`, `date_modified`, `deleted`) VALUES (UUID(), (SELECT `id` FROM contacts WHERE `phone_work` LIKE '%'+NEW.src LIMIT 1), NEW.id, NOW(), 0);";
	
	$result = $GLOBALS['db']->query($query); 
	
	if($result) 
		echo 'Trigger ustawiony :D';
	else
		echo 'Blad ustawienia triggera :(';
	
?>