Переименовал классы и добавил выборку из второй БД

This commit is contained in:
2024-08-08 16:38:54 +03:00
parent 1f96b88ac2
commit 0b56cd37b5
8 changed files with 113 additions and 90 deletions

View File

@ -1,35 +1,48 @@
<?php
namespace App;
use App\Library\SvedenParser;
use App\Library\ContingentParser;
use App\Library\Database;
use GuzzleHttp\Client;
$dbconfig = [
"host" => "10.90.1.201",
"database" => "opendata",
"database1" => "opendata",
"database2" => "niimko",
"user" => "niimko_user",
"password" => "MOhA17FeboXE"
];
$client = new Client();
$response = $client->get('https://marsu.ru/sveden/education/eduChislen.php');
$html = $response->getBody()->getContents();
$parser = new SvedenParser($html, '//tr[@itemprop="eduChislen"]//');
$data = $parser->getDataTable();
$db = new Database(
"mysql:host={$dbconfig['host']};dbname={$dbconfig['database']}",
$dbOpendata = new Database(
"mysql:host={$dbconfig['host']};dbname={$dbconfig['database1']}",
$dbconfig['user'],
$dbconfig['password']
);
// print_r($data);
$dbNiimko = new Database(
"mysql:host={$dbconfig['host']};dbname={$dbconfig['database2']}",
$dbconfig['user'],
$dbconfig['password']
);
// $db->insert('sveden_table_education', $data);
$data = $db->select('sveden_education_contingent');
$client = new Client();
$response = $client->get('https://marsu.ru/sveden/education/eduChislen.php');
$html = $response->getBody()->getContents();
$parser = new ContingentParser($html, '//tr[@itemprop="eduChislen"]//');
$contingent = $parser->getDataTable();
$specializations = $dbNiimko->selectWhere('s_specs', ['id', 'kod'], ['oopkodes' => 'gos3p']);
foreach ($contingent as $key => $con) {
$needle = $con['spec_code'];
foreach ($specializations as $spec) {
if ($needle == $spec['kod']) {
$contingent[$key] += ['spec_id' => $spec['id']];
}
}
}
// $dbOpendata->insert('sveden_education_contingent', $data);
// $dbOpendata = $db->select('sveden_education_contingent');
echo "<pre>";
print_r($data);
print_r($contingent);
echo "</pre>";