Confetti Bits

CB_Events_Event
in package

Handles the creation and management of events.

Tags
since
3.0.0

Table of Contents

Properties

$date_created  : string
The date the event was created.
$date_modified  : string
The date of the last time the entry was modified.
$event_desc  : string
The description of the event.
$event_end  : datetime
The date and time that the event ends.
$event_start  : datetime
The date and time that the event starts.
$event_title  : string
The title of the event.
$id  : int
The ID of the event entry.
$participation_amount  : int
The amount that the user will receive for participating in the event.
$user_id  : int
The ID of the user who created the event.
$columns  : array<string|int, mixed>
The columns available in the database. Used to help build our orderby clause.

Methods

__construct()  : mixed
Constructor
delete()  : int|false
Delete Delete the event from the database.
exists()  : mixed
Determines whether the given Event exists in the database.
get_date_query_sql()  : string
Get Date Query SQL.
get_events()  : array<string|int, mixed>
Get Event
get_member_data()  : An
A general purpose method to retrieve member profile data. Used with BuddyBoss Platform. Will not work if you don't have that. Will we replace it? Maybe someday. I would like to. But I have two hands, and barely three brain cells; have mercy, I beg your pardon.
get_orderby_sql()  : string
Get Orderby SQL.
populate()  : mixed
Get information for specific event.
save()  : int|WP_Error
Save Save the event to the database.
update()  : int|false
Update Update the event in the database.
_delete()  : int|false
Delete event entry.
_insert()  : int|WP_Error
_insert Insert event entry into the database.
_update()  : int|false
Update event entry.
get_paged_sql()  : string
Assemble the LIMIT clause of a get() SQL statement.
get_query_clauses()  : array<string|int, mixed>
Assemble query clauses, based on arguments, to pass to $wpdb methods.
get_where_sql()  : string
Get WHERE SQL.

Properties

$date_modified

The date of the last time the entry was modified.

public string $date_modified

$participation_amount

The amount that the user will receive for participating in the event.

public int $participation_amount

$columns

The columns available in the database. Used to help build our orderby clause.

private static array<string|int, mixed> $columns = ['id', 'event_title', 'event_desc', 'event_start', 'event_end', 'participation_amount', 'user_id', 'date_created', 'date_modified']

Methods

__construct()

Constructor

public __construct([mixed $id = 0 ]) : mixed

If an ID is supplied, populate information about that event.

Parameters
$id : mixed = 0

delete()

Delete Delete the event from the database.

public static delete([array<string|int, mixed> $where_args = [] ]) : int|false
Parameters
$where_args : array<string|int, mixed> = []

Associative array of columns/values, to determine which rows should be updated. Of the format [ 'item_id' => 7, 'component_action' => 'cb_event', ).

Return values
int|false

Number of rows updated on success, false on failure.

exists()

Determines whether the given Event exists in the database.

public exists([mixed $id = 0 ]) : mixed

Because we can't easily use foreign keys in a WordPress instance, we'll have to check ourselves whether

Parameters
$id : mixed = 0

get_date_query_sql()

Get Date Query SQL.

public static get_date_query_sql([array<string|int, mixed> $date_query = [] ]) : string
Parameters
$date_query : array<string|int, mixed> = []

Date query arguments.

Tags
since
3.0.0
access

public

Return values
string

Date query SQL.

get_member_data()

A general purpose method to retrieve member profile data. Used with BuddyBoss Platform. Will not work if you don't have that. Will we replace it? Maybe someday. I would like to. But I have two hands, and barely three brain cells; have mercy, I beg your pardon.

public get_member_data([array<string|int, mixed> $args = [] ]) : An
Parameters
$args : array<string|int, mixed> = []

{ An opinionated albeit mostly optional array of arguments. @type string|array $select Columns you want to select. @type array $where Key-value pairs of parameters to pack into a WHERE clause. @type array $orderby [ 'column' => 'my_column', 'order' => 'ASC_or_DESC' ] @type array $pagination [ 'page' => 1+, 'per_page' => 1+ ] @type string $group Columns you want to group by. }

Tags
since
3.0.1
Return values
An

array of members whose data is in an associative array format.

get_orderby_sql()

Get Orderby SQL.

public static get_orderby_sql([array<string|int, mixed> $args = [] ]) : string

Checks against the columns available and order arguments, then spits out usable SQL if everything looks okay.

Parameters
$args : array<string|int, mixed> = []

{ Optional. An array of arguments.

@type string $column Default 'id'. The column to order by.
@type string $order Default 'DESC'. The order of the items.

}

Return values
string

The ORDER BY clause of an SQL query, or nothing if the args are empty or malformed.

populate()

Get information for specific event.

public populate([int $id = 0 ]) : mixed
Parameters
$id : int = 0

The ID of the event to fetch.

Tags
since
3.0.0
uses
CB_Events_Event::get_event()

save()

Save Save the event to the database.

public save() : int|WP_Error
Tags
since
1.0.0
access

public

uses
CB_Events_Event::_insert()
Return values
int|WP_Error

The ID of the event if successful, WP_Error otherwise.

update()

Update Update the event in the database.

public static update([array<string|int, mixed> $update_args = [] ][, array<string|int, mixed> $where_args = [] ]) : int|false
Parameters
$update_args : array<string|int, mixed> = []

Associative array of fields to update, and the values to update them to. Of the format [ 'applicant_id' => 4, 'component_action' => 'cb_event', ).

$where_args : array<string|int, mixed> = []

Associative array of columns/values, to determine which rows should be updated. Of the format [ 'item_id' => 7, 'component_action' => 'cb_event', ).

Return values
int|false

Number of rows updated on success, false on failure.

_delete()

Delete event entry.

protected static _delete([array<string|int, mixed> $where = [] ][, array<string|int, mixed> $where_format = [] ]) : int|false
Parameters
$where : array<string|int, mixed> = []

The WHERE params as passed to wpdb::delete(). Typically consists of [ 'ID' => $id ) to specify the ID of the item being deleted. See .

$where_format : array<string|int, mixed> = []

See .

Tags
since
1.0.0
access

protected

uses
wpdb::delete()
uses
Confetti_Bits_Event_Event::get_where_sql()
Return values
int|false

The number of rows updated, or false on error.

_insert()

_insert Insert event entry into the database.

protected static _insert([array<string|int, mixed> $data = [] ][, array<string|int, mixed> $data_format = [] ]) : int|WP_Error
Parameters
$data : array<string|int, mixed> = []

Array of event data to insert, passed to . Accepts any property of a Confetti_Bits_Event_Event object.

$data_format : array<string|int, mixed> = []

See . Default [ '%s', '%s', '%s', '%d', '%d', '%d', '%s', '%s' ).

Tags
since
1.0.0
access

protected

uses
wpdb::insert()
used-by
CB_Events_Event::save()
Return values
int|WP_Error

The ID of the event if successful, WP_Error otherwise.

_update()

Update event entry.

protected static _update([array<string|int, mixed> $data = [] ][, array<string|int, mixed> $where = [] ][, array<string|int, mixed> $data_format = [] ][, array<string|int, mixed> $where_format = [] ]) : int|false
Parameters
$data : array<string|int, mixed> = []

Array of event data to update, passed to . Accepts any property of a Confetti_Bits_Events_Event object.

$where : array<string|int, mixed> = []

The WHERE params as passed to wpdb::update(). Typically consists of [ 'ID' => $id ) to specify the ID of the item being updated. See .

$data_format : array<string|int, mixed> = []

See .

$where_format : array<string|int, mixed> = []

See .

Tags
see
wpdb::update()

for further description of paramater formats.

Return values
int|false

The number of rows updated, or false on error.

get_paged_sql()

Assemble the LIMIT clause of a get() SQL statement.

protected static get_paged_sql([array<string|int, mixed> $args = [] ]) : string

Used to create a LIMIT clause.

Parameters
$args : array<string|int, mixed> = []

Array consisting of the page number and items per page. { @type int $page page number @type int $per_page items to return }

Return values
string

$retval LIMIT clause.

get_query_clauses()

Assemble query clauses, based on arguments, to pass to $wpdb methods.

protected static get_query_clauses([array<string|int, mixed> $args = [] ]) : array<string|int, mixed>

The insert(), update(), and delete() methods of expect arguments of the following forms:

  • associative arrays whose key/value pairs are column => value, to be used in WHERE, SET, or VALUES clauses.
  • arrays of "formats", which tell $wpdb->prepare() which type of value to expect when sanitizing (eg, [ '%s', '%d' ))

This utility method can be used to assemble both kinds of params, out of a single set of associative array arguments, such as:

$args = [
    'user_id' => 4,
    'component_name' => 'groups',
);

This will be converted to:

[
    'data' => [
        'user_id' => 4,
        'component_name' => 'groups',
    ),
    'format' => [
        '%d',
        '%s',
    ),
)

which can easily be passed as arguments to the $wpdb methods.

Parameters
$args : array<string|int, mixed> = []

Associative array of filter arguments.

Return values
array<string|int, mixed>

Associative array of 'data' and 'format' args.

get_where_sql()

Get WHERE SQL.

protected static get_where_sql([array<string|int, mixed> $args = [] ]) : string
Parameters
$args : array<string|int, mixed> = []

{ @type int $id Event ID. @type int $user_id User ID. @type string $event_title Event title. @type string $event_desc Event description. @type string $event_date_query Date query. }

Tags
see
CB_Events_Event::get_date_query_sql()
since
3.0.0
access

protected

Return values
string

WHERE SQL.


        
On this page

Search results