// set_time_limit(1000); // global $wpdb; // $results = $wpdb->get_results("SELECT * FROM sales_force_accounts_data_to_import "); // $update_count=$insert_count=0; // foreach ($results as $r) { // if($r->account_id_sf){ // $postdata = array('post_title' => $r->title, 'post_type' => 'salesforce-accounts', 'post_status' => 'publish'); // $posts = get_posts(array( // 'numberposts' => 1, // 'post_type' => 'salesforce-accounts', // 'meta_key' => 'account_id_sf', // 'meta_value' => $r->account_id_sf // )); // if ($posts) { // foreach($posts as $post){ // $post_id = $post->ID; // $update_count++; // } // } else { // $insert_count++; // $post_id = wp_insert_post($postdata); // // print_r($post); // if (is_wp_error($post)) { // print_r($row); // //post not created because credentials exists // $error_row['data'] = $row; // $error_row['error_object'] = $post; // $error_rows[] = $error_row; // } // } // update_post_meta($post_id, 'close_account_date_sf', $r->close_account_date_sf); // update_post_meta($post_id, 'account_active_sf', $r->account_active_sf); // update_post_meta($post_id, 'account_id_sf', $r->account_id_sf); // update_post_meta($post_id, 'created_date_sf', $r->created_date_sf); // update_post_meta($post_id, 'billing_street_sf', $r->billing_street_sf); // update_post_meta($post_id, 'billing_city_sf', $r->billing_city_sf); // update_post_meta($post_id, 'billing_state_sf', $r->billing_state_sf); // update_post_meta($post_id, 'phone_sf', $r->phone_sf); // update_post_meta($post_id, 'website_sf', $r->website_sf); // update_post_meta($post_id, 'billing_postal_code_sf', $r->billing_postal_code_sf); // update_post_meta($post_id, 'billing_country_sf', $r->billing_country_sf); // update_post_meta($post_id, 'golf_club_alias', $r->golf_club_alias); // update_post_meta($post_id, 'business_categories', $r->business_categories); // update_post_meta($post_id, 'golf_clubs_sponsored', $r->golf_clubs_sponsored); // } // } // echo 'New records= '.$insert_count.' Updated records= '.$update_count;