<?php
declare(strict_types=1);
// One zero-row business SELECT plus its normal schema metadata. No HTTP/DML.
if(getenv('SM7_LANE')!=='C'){exit(78);}
$root=getenv('SM7_ROOT');$parent=getenv('SM7_PARENT');$runtime=getenv('SM7_RUNTIME');require $parent.'/env.php';define('APP_PATH',$root.'/application/');define('RUNTIME_PATH',$runtime.'/diag-runtime/');
require $parent.'/thinkphp/base.php';\think\App::initCommon();$db=require $parent.'/application/database.php';$db['debug']=true;\think\Config::set($db,'database');\think\Db::clear();\think\Config::set('redis',[]);\think\Config::set(['type'=>'File','path'=>$runtime.'/diag-cache/','prefix'=>'SM7_DIAG_'],'cache');\think\Log::init(['type'=>'File','path'=>$runtime.'/diag-log/','level'=>['no_raw_application_log']]);
require __DIR__.'/SqlCoverageRecorder.php';$events=[];\think\Db::listen(static function($sql,$time=null)use(&$events){if(strpos($sql,'CONNECT:')!==0){$f=SqlCoverageRecorder::fingerprint($sql);$events[]=['sql'=>$sql,'fingerprint'=>$f];}});
$rows=(new \app\model\EquipmentVersion())->whereRaw('1=0')->select()->toArray();
$file=$runtime.'/observer-diag-private.json';file_put_contents($file,json_encode(['rows'=>count($rows),'queries'=>$events],JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR));chmod($file,0600);echo json_encode(['rows'=>count($rows),'queries'=>count($events),'warnings'=>count(array_filter($events,static function($e){return $e['fingerprint']['lexical_warning'];})),'dml'=>0,'ddl'=>0,'new_http'=>0]),PHP_EOL;
