Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "skillzdev";
- $dbname1 = "skillz";
- $dbname2 = "skillz_dev";
- // Create connection
- $conn1 = new mysqli($servername, $username, $password, $dbname1);
- // Check connection
- if ($conn1->connect_error) {
- die("Connection failed: " . $conn1->connect_error);
- }
- $conn2 = new mysqli($servername, $username, $password, $dbname2);
- // Check connection
- if ($conn2->connect_error) {
- die("Connection failed: " . $conn2->connect_error);
- }
- $sql = "SELECT
- news_id AS id,
- lang_code AS locale,
- user_id AS author,
- title AS title,
- text AS content,
- FROM_UNIXTIME(date) AS posted,
- news.comments AS comments
- FROM news_translates
- LEFT JOIN news ON news_translates.news_id = news.id
- WHERE lang_code='lv' AND active=1";
- $result = $conn1->query($sql);
- foreach ($result as $key => $translate_lv) {
- $id = $translate_lv['id'];
- $lang = $translate_lv['local'];
- $author = $translate_lv['author'];
- $title = $translate_lv['title'];
- $text = $translate_lv['content'];
- $posted = $translate_lv['posted'];
- $comments = $translate_lv['comments'];
- $sql_lat = "INSERT INTO sk_posts (post_author,post_date,post_date_gmt,post_content,post_title,post_excerpt,post_status,comment_status,ping_status,post_password,post_name,to_ping,pinged,post_modified,post_modified_gmt,post_content_filtered,post_parent,guid,menu_order,post_type,post_mime_type,comment_count)
- VALUES ($author, $posted, $posted, $text, $title, '', 'publish', 'open', 'open', $id, '', '' , $posted, $posted, '', 0, 'http://skillz.dev/?p='.$id, 0, 'post', '', $comments)";
- $conn2->query($sql_lat);
- $latId = $conn2->insert_id;
- $sql2 = $sql = "SELECT
- news_id AS id,
- lang_code AS locale,
- user_id AS author,
- title AS title,
- text AS content,
- FROM_UNIXTIME(date) AS posted,
- news.comments AS comments
- FROM news_translates
- LEFT JOIN news ON news_translates.news_id = news.id
- WHERE lang_code='ru' AND active=1 AND news_id=$latId";
- $result = $conn1->query($sql2);
- $id = $result['id'];
- $lang = $result['local'];
- $author = $result['author'];
- $title = $result['title'];
- $text = $result['content'];
- $posted = $result['posted'];
- $comments = $result['comments'];
- $sql_ru = "INSERT INTO sk_posts (post_author,post_date,post_date_gmt,post_content,post_title,post_excerpt,post_status,comment_status,ping_status,post_password,post_name,to_ping,pinged,post_modified,post_modified_gmt,post_content_filtered,post_parent,guid,menu_order,post_type,post_mime_type,comment_count)
- VALUES ($author, $posted, $posted, $text, $title, '', 'publish', 'open', 'open', $id, '', '' , $posted, $posted, '', 0, 'http://skillz.dev/?p='.$id, 0, 'post', '', $comments)";
- $conn2->query($sql_ru);
- $ruId = $conn2->insert_id;
- $poly = 'pll_'.md5(uniqid(rand(), true));
- $pollyIns = "INSERT INTO sk_terms (name, slug, term_group)
- VALUES ($poly, $poly, 0)";
- $conn2->query($pollyIns);
- $pollyId = $conn2->insert_id;
- $translations = ['lv'=>$latId, 'ru'=>$ruId]
- $dbTranslations = serialize($translations);
- $sqlTransl = "INSERT INTO sk_term_taxonomy (term_id, taxonomy, description, parent, count)
- VALUES ($pollyId, 'post_translations', $dbTranslations, 0, 2)";
- $conn2->query($sqlTransl);
- }
- echo 'DOne';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement