При неудаче в запросе к БД валидные данные сохраняются в yaml-файл (script.php)
This commit is contained in:
54
script.php
54
script.php
@ -1,28 +1,36 @@
|
||||
<?php
|
||||
// require_once(dirname(__FILE__) ."/app/library/Database.php");
|
||||
// require_once(dirname(__FILE__) ."/app/library/DatabaseConfig.php");
|
||||
// use App\Library\Database;
|
||||
// use App\Library\DatabaseConfig;
|
||||
use App\Library\ContingentManager;
|
||||
use App\Library\Database;
|
||||
use App\Library\DatabaseConfig;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
// При ошибке в запросе к БД. Распарсингованные данные
|
||||
// сохраняются в yaml-файле. Скрипт парсит этот файл и заносит в БД
|
||||
require_once "vendor/autoload.php";
|
||||
|
||||
// $dbOpendata = new Database(new DatabaseConfig('opendata'));
|
||||
// $sql = 'SELECT DISTINCT org_id FROM sveden_education_contingent';
|
||||
// $org = $dbOpendata->selectQuery($sql);
|
||||
// $orgs = [];
|
||||
// foreach ($org as $o) {
|
||||
// $orgs[] = $o['org_id'];
|
||||
// }
|
||||
// unset($org);
|
||||
function array_depth(array $array) {
|
||||
$max_depth = 1;
|
||||
|
||||
// print_r($orgs);
|
||||
foreach ($array as $value) {
|
||||
if (is_array($value)) {
|
||||
$depth = array_depth($value) + 1;
|
||||
|
||||
// $filename = 'error-html.log';
|
||||
// $array = file($filename);
|
||||
// for ($i = 0; $i < count($array); $i++) {
|
||||
// $arr = explode(' ', $array[$i]);
|
||||
// if (!in_array($arr[2], $orgs)) {
|
||||
// //file_put_contents(__DIR__ . '/error-html2.log', $array[$i], FILE_APPEND);
|
||||
// }
|
||||
// }
|
||||
if ($depth > $max_depth) {
|
||||
$max_depth = $depth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var_dump("eduLеvel" != "eduLevel");
|
||||
var_dump("eduCode" == "eduCode");
|
||||
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, $arr);
|
||||
} else {
|
||||
foreach ($data as $value) {
|
||||
// ContingentManager::getInstance()->insertContingent($db, $value);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user