Обновлены настройки Client, дозапись в базу
This commit is contained in:
37
add_recording.php
Normal file
37
add_recording.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
use App\Library\ContingentManager;
|
||||
use App\Library\Database;
|
||||
use App\Library\DatabaseConfig;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
// При ошибке в запросе к БД. Распарсингованные данные
|
||||
// сохраняются в yaml-файле. Скрипт парсит этот файл и заносит в БД
|
||||
require_once "vendor/autoload.php";
|
||||
|
||||
function array_depth(array $array)
|
||||
{
|
||||
$max_depth = 1;
|
||||
|
||||
foreach ($array as $value) {
|
||||
if (is_array($value)) {
|
||||
$depth = array_depth($value) + 1;
|
||||
|
||||
if ($depth > $max_depth) {
|
||||
$max_depth = $depth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $max_depth;
|
||||
}
|
||||
|
||||
$data = Yaml::parse(file_get_contents(__DIR__ . '/not-recorded-in-db.yaml'));
|
||||
$db = new Database(new DatabaseConfig('opendata'));
|
||||
// $orgs = ContingentManager::getInstance()->getOrgs($dbOpendata);
|
||||
|
||||
if(array_depth($data) == 2){
|
||||
ContingentManager::getInstance()->insertContingent($db, $data);
|
||||
} else {
|
||||
foreach ($data as $value) {
|
||||
ContingentManager::getInstance()->insertContingent($db, $value);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user