<?php
require __DIR__.'/oracle.php';$gate=json_decode(file_get_contents(__DIR__.'/private-fixture-gate.json'),true);$check($gate['passed'],'Full fixture gate first');$guard($source(),false);$check(!is_file(__DIR__.'/private-fixture-own.json'),'No fixture replay');$db->beginTransaction();try{foreach($fixture['write']as $t=>$rows)foreach($rows as $r){$sql='INSERT INTO '.$p.$t.' ('.implode(',',array_keys($r)).') VALUES ('.implode(',',array_fill(0,count($r),'?')).')';$s=$db->prepare($sql);$s->execute(array_values($r));}$own=[];foreach($fixture['write']as $t=>$rows){$own[$t]=$q('SELECT * FROM '.$p.$t.' WHERE STAFF_UUID=? ORDER BY ID',[$fixture['staff']['uuid']]);$check(count($own[$t])===2,'Exactly two own rows');foreach($rows as $i=>$r)foreach($r as $k=>$v){$actual=$own[$t][$i][$k];if($k==='create_time')$actual=preg_replace('/\.0{1,6}$/','',(string)$actual);if($k==='weight'&&$t==='member_weight')$check((float)$actual===(float)$v,'Stored FLOAT exact small value');else $check((string)$actual===(string)$v,'Stored explicit field '.$t.'.'.$k);}$check((int)$own[$t][0]['id']>0&&(int)$own[$t][1]['id']>(int)$own[$t][0]['id'],'Generated distinct PK');}$db->commit();$save('private-fixture-own.json',$own);}catch(Throwable $e){$db->rollBack();throw $e;}$s=$source();$guard($s);$save('private-fixture-after.json',$s);echo json_encode(['lane'=>$lane,'passed'=>true,'transaction_INSERTs'=>4,'rows'=>array_map('count',$own),'PKs'=>array_map(static function($r){return array_column($r,'id');},$own),'natural_unchanged'=>true,'references_unchanged'=>true]),"\n";
