Confetti Bits

cb-ajax-contests.php

All of our CRUD functions for contests.

Tags
since
3.0.0

Table of Contents

Functions

cb_ajax_new_contests()  : mixed
Accepts either a singular contest object or an array of contest objects and adds them to the database.
cb_ajax_update_contests()  : mixed
Updates contest objects for a given event.
cb_ajax_delete_contests()  : mixed
Deletes existing contest objects from the database.
cb_ajax_get_contests()  : mixed
Retrieves contest objects from the database.

Functions

cb_ajax_new_contests()

Accepts either a singular contest object or an array of contest objects and adds them to the database.

cb_ajax_new_contests() : mixed
Tags
since
3.0.0

cb_ajax_update_contests()

Updates contest objects for a given event.

cb_ajax_update_contests() : mixed

I'm a goofy goober. I ended up making this a lot more dynamic so it can handle a lot of different user interactions.

Sit back and enjoy, friend.

It's important to note that we aren't necessarily always modifying a singular contest object within the database. Here's a breakdown of what's going on here:

Arguments
  • An event_id
  • An array of contest objects, with 'placement' and 'amount' keys
  • An API key
Data Logistics
  1. Validate that we meet all the above constraints.
  2. Validate that the event actually exists in the database.
  3. Loop through the contests, and within that loop: a. Validate that we have both a placement and an amount. b. Check to see if that placement exists, and update it if so. c. If the placement doesn't exist, we'll create one.

Should be fairly straightforward, but I've been wrong so many times before. ~~We might just run everything through the new_contests endpoint~~ ~~We're almost definitely going to be running updates through the new_contests endpoint.~~

We are absolutely not running updates through the new_contests endpoint.

Tags
subpackage

Contests

since
3.0.0

cb_ajax_delete_contests()

Deletes existing contest objects from the database.

cb_ajax_delete_contests() : mixed
Tags
since
3.0.0

cb_ajax_get_contests()

Retrieves contest objects from the database.

cb_ajax_get_contests() : mixed

Typically used to retrieve a list of placements based on a given event_id.

Tags
subpackage

Contests

since
3.0.0

        
On this page

Search results