PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $query = " -- создаем таблицу учёта рабочего времени create table job ( person text not null, reported real not null check (reported >= 0.0) ); -- создаем таблицу с общим временем работы create table total ( person text unique not null, hours real ); -- создаем триггер для обновления таблицы `total` create trigger total_trigger before insert on job begin select case when not exists (select 1 from total where person = new.person) then raise(rollback, 'Unknown person ') end; insert into total values (new.person, new.reported) on conflict(person) do update set hours = hours + new.reported; end; insert into job values ('Олег', 1.5), ('Сергей', 0.5), ('Олег', 1.0); select * from total; "; if ( preg_match('/^(CREATE\s+(OR\s+REPLACE\s+)?(PROCEDURE|FUNCTION|TRIGGER).+?[IS|AS].+?BEGIN.+?END\s?;)/ims', $query, $matches)) { echo mb_strlen($matches[1]); echo $matches[1]; }
Show:  
Copy Clear