使用PHP中的wpdb插入数据库

I try to make a function to insert more fields in database. I find an example, but maybe more parameters is deprecated...or i have an error.

Here is my code:

private function _setUserPersonalDetails($blog_id, $personal_data, $operation = 'insert') {
    global $wpdb;

    // Strip any html tags from the about and address fields.
    $tmp = array();
    foreach ($personal_data as $key => $val) {
      if (($key === 'about') || ($key === 'address')) {
        $tmp[$key] = strip_tags($val);
      }
      else {
        $tmp[$key] = $val;
      }
    }
    $personal_data = $tmp;

    if ($operation == 'insert') {
      // Save personal data
      $encoded_data = json_encode($personal_data);
      $type = 'personal_data';
      $q = $wpdb->prepare('INSERT INTO wp0_users_conta_data (blog_id, type, data) VALUES (%d, %s, %s)', $blog_id, $type, $encoded_data);
      $wpdb->query($q);
    }

    if ($operation == 'update') {
      // Update personal data
      $encoded_data = json_encode($personal_data);
      $type = 'personal_data';
      $q = $wpdb->prepare('UPDATE wp0_users_conta_data set data=%s where blog_id=%d and type=%s', $encoded_data, $blog_id, $type);
      $wpdb->query($q);
    }
  }
}

I spent more one week to solve the problem, but i don't find any solutions. I appreciate any helps. Thank you!