43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
|
<?php
|
||
|
/* ----------------------------------------------------------------------
|
||
|
13.12.2022
|
||
|
Конвертируем сайт tk-ligat
|
||
|
---------------------------------------------------------------------- */
|
||
|
require_once('/home/cloud/core/api/php/db.php');
|
||
|
|
||
|
DB::$type='sqlite3';
|
||
|
//DB::$path='/home/www/tk-ligat.ru/bd/etalon.db';
|
||
|
|
||
|
function replace ($text) { // ФУНКЦИЯ очистки кода для xml
|
||
|
$old1 = array('\"');#Ищем вредное ">",, "<"
|
||
|
$new1 = array('"');#Меняем на полезное">", , "<"
|
||
|
$text = str_replace($old1, $new1, $text);#Собсно сама замена =)
|
||
|
return $text;
|
||
|
}
|
||
|
|
||
|
DB::$path='/home/cloud/core/bd/tk-ligat.ru.db';
|
||
|
|
||
|
|
||
|
$imgs=DB::getAll('SELECT `page_id`, `fileName` FROM `img`');
|
||
|
|
||
|
for ($i=0; $i<count($imgs); $i++){
|
||
|
|
||
|
$idoldtovar=DB::getValue('SELECT `tovar_id` FROM `pages` WHERE `id` = "' . $imgs[$i]['page_id'] . '" LIMIT 1');
|
||
|
|
||
|
$idreal=DB::getValue('SELECT `id` FROM "tovar" WHERE `tovar_id_1c` = "' . $idoldtovar . '" LIMIT 1');
|
||
|
|
||
|
|
||
|
$id=DB::add("INSERT INTO `tovar_img` (`filename`, `tovar_id`) VALUES (?, ?)",
|
||
|
array(
|
||
|
$imgs[$i]['fileName'],
|
||
|
$idreal
|
||
|
));
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
print_r($pages);
|
||
|
|
||
|
|
||
|
|
||
|
?>
|