Files
EdgeManager/app/EDataCapture/EDataCapture.php

33 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace EdgeManager\EDataCapture;
class EDataCapture {
// 我不主张在构造函数内实现类型检查,因为在请求过于密集、记录较多时会严重影响性能
// 请使用SCADA系统的开发人员自觉遵守文档内规范
function __construct(
protected $dbconn,
protected $post = NULL,
protected $get = NULL
) {}
private function set_data() {
foreach (array_chunk($this -> post -> param, 6507524, true) as $chunk) {
$sql_cmd[] = [sprintf(
"INSERT INTO hf_mes_scada_data_capture_node_data_%s",
$chunk[0] -> working_subclass
)];
foreach ($chunk as $row) {
$sql_cmd[] = sprintf(
"(code, v_%s, device_code, batch) VALUES('%s', %s, %s, %s)",
$row -> type,
$row -> code,
$row -> value,
$row -> device_code ?? NULL,
$row -> batch ?? NULL
);
}
return pg_query($this -> dbconn, implode(' ', $sql_cmd));
}
}
}