habibjutt
1/8/2016 - 10:44 AM

wp adding data to custom database table.php

global $wpdb;
        $last_id = $wpdb->get_var("SELECT * FROM $wpdb->posts ORDER BY ID DESC LIMIT 0, 1");

        $wpdb->insert(
                'wp_phone_orders', array(
            'post_id' => $last_id,
            'user_id' => $_SESSION['current_user']['id'],
            'admin_switched_id' => $_SESSION['checkout_data']['admin-switched-id'],
            'admin_email_switched' => $_SESSION['checkout_data']['admin-email-switched'],
            'user_email' => static::get_email($_SESSION['current_user']['id']),
            'admin_user_name_switched' => $_SESSION['checkout_data']['admin-user-name-switched'],
            'admin_role_switched' => $_SESSION['checkout_data']['admin-role-switched']
                ), array(
            '%d',
            '%d',
            '%d',
            '%s',
            '%s',
            '%s',
            '%s'
                )
        );