26 lines
1.1 KiB
PHP
26 lines
1.1 KiB
PHP
<?php
|
|
|
|
ini_set('display_errors', 1);
|
|
$_SERVER['SERVER_NAME'] = 'tk-ligat.ru';
|
|
require_once('/home/cloud/core/set/tk-ligat.ru.php');
|
|
require_once('/home/cloud/core/api/php/db.php');
|
|
require_once('/home/cloud/core/api/php/json.php');
|
|
|
|
function upd ($id, $title){
|
|
DB::set("UPDATE `tovar_category` SET `status`=0 WHERE `title`=?", $title);
|
|
DB::set("UPDATE `tovar_category` SET `status`=1 WHERE `id`=?", $id);
|
|
$massiv=DB::getAll("SELECT `id`, `category` FROM `tovar_category` WHERE `title`=? AND `id`<>?", array($title, $id));
|
|
for ($i=0; $i<count($massiv); $i++){
|
|
DB::set("UPDATE `tovar_category` SET `category`=? WHERE `category`=?", array($id, $massiv[$i]['id']));
|
|
DB::set("UPDATE `tovar` SET `category`=? WHERE `category`=?", array($id, $massiv[$i]['id']));
|
|
}
|
|
}
|
|
|
|
$cats = DB::getAll("SELECT `title`, `id`, `category` FROM `tovar_category` WHERE `status`=1");
|
|
for ($i = 0; $i < count($cats); $i++) {
|
|
$count = DB::getAll("SELECT count(*) FROM `tovar_category` WHERE `title`=?", $cats[$i]['title'])[0]["count(*)"];
|
|
if ($count > 1) {
|
|
upd($cats[$i]['id'], $cats[$i]['title']);
|
|
}
|
|
}
|
|
?>
|