Задать вопрос
@yantotal

Wp_insert_post — почему останавливается импорт?

Привет! Пытаюсь импортировать базу 4.5 млн
Импорт останавливается после 200 тысяч.. Ошибок не видно. Какие есть способы решения?
for ($l = 0; $l <= 890; $l++) {
    $dbh = mysqli_connect($host, $user, $pswd) or die("Не могу соединиться с MySQL.");
    mysqli_select_db($dbh, $database) or die("Не могу подключиться к базе.");
    $limit = $l * 5000;
    $sql = "SELECT `NPI`, `Provider_Last_Name_Legal_Name`, `Provider_First_Name`, `Provider_Middle_Name`, `Provider_Name_Prefix_Text`, `Provider_Name_Suffix_Text`, `Provider_First_Line_Business_Mailing_Address`, `Provider_Second_Line_Business_Mailing_Address`, `Provider_Business_Practice_Location_Address_City_Name`, `Provider_Business_Practice_Location_Address_State_Name`, `Provider_Business_Practice_Location_Address_Postal_Code`, `Provider_Business_Practice_Location_Address_Telephone_Number`, `Provider_Business_Practice_Location_Address_Fax_Number`, `Provider_Gender_Code`, `Provider_First_Line_Business_Practice_Location_Address` FROM `npi` WHERE `used` != 1 AND `Provider_Last_Name_Legal_Name` != ''  LIMIT ".$limit.", 50000";
    $res = mysqli_query($dbh, $sql);
    $i = 0;

    while ($row = mysqli_fetch_array($res, MYSQLI_ASSOC)) {
        $post_title = $row['Provider_First_Name'] . ' ' . $row['Provider_Middle_Name'] . ' ' . $row['Provider_Last_Name_Legal_Name'];
        $defaults = array(
            'post_status' => 'publish',
            'post_type' => 'doctor',
            'post_author' => 1,
            'post_title' => $post_title
        );
        $post_id = wp_insert_post($defaults, $wp_error);
        update_post_meta($post_id, 'npi_number', $row['NPI']);
        update_post_meta($post_id, 'provider_name_prefix_text', $row['Provider_Name_Prefix_Text']);
        update_post_meta($post_id, 'provider_name_prefix_text', $row['Provider_Name_Prefix_Text']);
        update_post_meta($post_id, 'provider_name_suffix_Text', $row['Provider_Name_Suffix_Text']);
        update_post_meta($post_id, 'provider_first_line_business_mailing_address', $row['Provider_First_Line_Business_Mailing_Address']);
        update_post_meta($post_id, 'provider_second_line_business_mailing_address', $row['Provider_Second_Line_Business_Mailing_Address']);
        update_post_meta($post_id, 'provider_business_practice_location_address_city_name', $row['Provider_Business_Practice_Location_Address_City_Name']);
        update_post_meta($post_id, 'provider_business_practice_location_address_state_name', $row['Provider_Business_Practice_Location_Address_State_Name']);
        update_post_meta($post_id, 'zip', $row['Provider_Business_Practice_Location_Address_Postal_Code']);
        update_post_meta($post_id, 'provider_business_practice_location_address_telephone_number', $row['Provider_Business_Practice_Location_Address_Telephone_Number']);
        update_post_meta($post_id, 'provider_business_practice_location_address_fax_number', $row['Provider_Business_Practice_Location_Address_Fax_Number']);
        update_post_meta($post_id, 'provider_gender_code', $row['Provider_Gender_Code']);
        update_post_meta($post_id, 'provider_first_line_business_practice_location_address', $row['Provider_First_Line_Business_Practice_Location_Address']);
        update_post_meta($post_id, 'is_npi', '1');
        $i++;
        unset($post_title, $row, $post_id, $defaults);
    }
    echo 'Cycle: '.$l."\n";
    unset($post_title, $row, $post_id, $defaults);
    sleep(1);
    mysqli_close ( $dbh );
    sleep(1);
}
  • Вопрос задан
  • 212 просмотров
Подписаться 2 Оценить Комментировать
Пригласить эксперта
Ответы на вопрос 1
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы