Добавлено логирование и исправлены некоторые ошибки в классах
This commit is contained in:
@ -31,11 +31,28 @@ final class ContingentManager
|
||||
->equals('fake', 'n')
|
||||
->end();
|
||||
$sql = $this->builder->write($query);
|
||||
$sites = $db->executeQuery($sql, $params);
|
||||
$sites = $db->selectQuery($sql, $params);
|
||||
|
||||
return $sites;
|
||||
}
|
||||
|
||||
public function insertContingent(Database $db, array $contingent) : void
|
||||
{
|
||||
$params = ['spec_code', 'spec_name', 'edu_level', 'edu_forms', 'contingent', 'spec_id', 'org_id'];
|
||||
$sql = "insert into sveden_education_contingent"
|
||||
."(". implode(',', $params) .") values";
|
||||
for ($i = 0; $i < count($contingent); $i++) {
|
||||
$sql .= "(";
|
||||
foreach ($contingent[$i] as $key => $value) {
|
||||
$sql .= ":$key". ($i+1).",";
|
||||
}
|
||||
$sql = substr_replace($sql,"),", -1);
|
||||
}
|
||||
$sql = substr_replace($sql,"", -1);
|
||||
|
||||
$db->insertQuery($sql, $contingent);
|
||||
}
|
||||
|
||||
public function getSpecializations(Database $db) : array
|
||||
{
|
||||
// select id, kod from niimko.s_specs where oopkodes = 'gos3p'
|
||||
@ -47,14 +64,19 @@ final class ContingentManager
|
||||
->equals('oopkodes','gos3p')
|
||||
->end();
|
||||
$sql = $this->builder->write($query);
|
||||
$specializations = $db->executeQuery($sql, $params);
|
||||
$specializations = $db->selectQuery($sql, $params);
|
||||
|
||||
return $specializations;
|
||||
}
|
||||
|
||||
public function buildURL(string $url): string
|
||||
{
|
||||
// TODO - сделать base_url
|
||||
// Строит -> https://<base_uri>/sveden/education/
|
||||
$offset = strpos($url, '/', strlen('http://'));
|
||||
if ($offset) {
|
||||
$url = substr_replace($url, '', $offset);
|
||||
}
|
||||
|
||||
$url = "$url/sveden/education/";
|
||||
if (str_contains($url, "http://")) {
|
||||
$url = str_replace("http://","https://", $url);
|
||||
@ -69,13 +91,15 @@ final class ContingentManager
|
||||
public function addSpecId(array &$contingent, array $specializations) : void
|
||||
{
|
||||
foreach ($contingent as $key => $con) {
|
||||
$buf = null;
|
||||
$needle = $con['spec_code'];
|
||||
foreach ($specializations as $spec) {
|
||||
if ($needle == $spec['kod']) {
|
||||
$cont['spec_id'] = $spec['id'];
|
||||
$buf = $spec['id'];
|
||||
}
|
||||
}
|
||||
$contingent[$key]['spec_id'] = $cont['spec_id'];
|
||||
$contingent[$key]['spec_id'] = $buf;
|
||||
unset($buf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,4 +109,13 @@ final class ContingentManager
|
||||
$contingent[$i]['org_id'] = $orgId;
|
||||
}
|
||||
}
|
||||
|
||||
public function checkContingent(array $contingent) : bool
|
||||
{
|
||||
$count = 0;
|
||||
foreach ($contingent as $value) {
|
||||
$count += $value['contingent'];
|
||||
}
|
||||
return $count ? true : false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user