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; create trigger another_trigger after update on job begin INSERT into job values ('Test', 1); END; insert into job values ('Олег', 1.5), ('Сергей', 0.5), ('Олег', 1.0); select * from total;"; $delimited = preg_match_all('/case.*?end/ims', $query, $matches); var_dump($matches);
Show:  
Copy Clear