function update_purchase($id, $user_id)
{
    global $wpdb;
    $purchase_table = get_purchases_table_name();
    $wpdb->update($purchase_table, array('user_id' => $user_id), array('id' => $id));
}
Ejemplo n.º 2
0
function build_line_items_sql()
{
    $line_items_table = get_line_items_table_name();
    $items_table = get_items_table_name();
    $purchases_table = get_purchases_table_name();
    $sql = "CREATE TABLE {$line_items_table} (\n    `purchase_id` int(10) NOT NULL,\n    `item_id` int(10) NOT NULL,\n    `price` decimal(10, 2),\n    PRIMARY KEY (`purchase_id`, `item_id`),\n    FOREIGN KEY (`purchase_id`) REFERENCES {$purchases_table}(`id`),\n    FOREIGN KEY (`item_id`) REFERENCES {$items_table}(`id`)\n    );";
    return $sql;
}