Confetti Bits

CB_Events_Contest
in package

CB_Events_Contest class.

Tags
since
3.0.0

Table of Contents

Properties

$amount  : int
The amount that the user will receive for the given placement in the contest.
$event_id  : int
The ID of the event that the contest is for.
$id  : int
The ID of the contest entry.
$placement  : int
The placement of the user in the contest.
$recipient_id  : int
The ID of the user that will receive the amount for the given placement in the contest.
$columns  : array<string|int, mixed>
The column names for the contest entry table.

Methods

__construct()  : mixed
Constructor
delete()  : int|false
Delete Delete the contest from the database.
get_contests()  : array<string|int, mixed>
Get Contest
get_date_query_sql()  : string
Get Date Query SQL.
get_orderby_sql()  : string
Assembles an ORDER BY clause from an array of fields and directions.
populate()  : mixed
Populates a contest object's properties from the database, based on contest ID.
save()  : int|bool
Save Save the contest to the database.
update()  : int|WP_Error
Update Update contest entry in the database.
_delete()  : int|false
Delete contest entry.
_insert()  : int|bool
_insert Insert contest entry into the database.
_update()  : int|false
Update contest 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
Assemble the WHERE clause of a get() SQL statement.

Properties

$amount

The amount that the user will receive for the given placement in the contest.

public int $amount

$recipient_id

The ID of the user that will receive the amount for the given placement in the contest.

public int $recipient_id

$columns

The column names for the contest entry table.

private static array<string|int, mixed> $columns = ['id', 'event_id', 'placement', 'amount', 'recipient_id']

Methods

__construct()

Constructor

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

Optional. The ID of the contest entry to populate.

Tags
since
3.0.0
access

public

delete()

Delete Delete the contest 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_contest', ).

Return values
int|false

Number of rows updated on success, false on failure.

get_contests()

Get Contest

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

{ @type string|array $select The columns to select. Default: '*' @type array $where { @type int $id The ID of the contest. @type int $event_id The ID of the event. @type int $placement The placement of the contest. @type int $amount The amount of the contest. @type int $recipient_id The ID of the recipient. @type string $date_created The date the contest was created. @type string $date_modified The date the contest was modified. } @type array $orderby { @type string $column The column to order by. @type string $order The order to sort by. Default: 'ASC' } @type array $pagination { @type int $page The page number. @type int $per_page The number of items per page. } @type string $group The column to group by. }

Tags
since
3.0.0
access

public

see
CB_Events_Contest::get_where_sql()
see
CB_Events_Contest::get_paged_sql()
see
CB_Events_Contest::get_orderby_sql()
Return values
array<string|int, mixed>

The contest(s), if found, as an associative array of objects.

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> = []

{ Array of date query clauses. @type string $column Column to query against. Accepts 'date_created', 'date_modified', or 'contest_date'. Default 'contest_date'. @type string $after Date to retrieve items after. Accepts MySQL datetime format. @type string $before Date to retrieve items before. Accepts MySQL datetime format. @type string $year 4 digit year (e.g. 2011). @type string $month 2 digit month (e.g. 02). @type string $day 2 digit day (e.g. 02). @type string $hour 2 digit hour (e.g. 15). @type string $minute 2 digit minute (e.g. 43). @type string $second 2 digit second (e.g. 33). @type string $compare Comparison operator to test. Accepts '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN', 'EXISTS' (only in WP >= 3.5), and 'NOT EXISTS' (also only in WP >= 3.5). Default '='. @type array $inclusive Whether the results should be inclusive or not. Accepts 'true' or 'false'. Default 'true'. @type string $relation Relation between date query clauses. Accepts 'AND' or 'OR'. Default 'AND'. }

Tags
since
3.0.0
access

public

Return values
string

Date query SQL.

get_orderby_sql()

Assembles an ORDER BY clause from an array of fields and directions.

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

{ @type string $field Field to order by. @type string $direction Direction to order by. Accepts 'ASC' or 'DESC'. Default 'ASC'. }

Tags
since
3.0.0
access

public

Return values
string

ORDER BY clause.

populate()

Populates a contest object's properties from the database, based on contest ID.

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

The ID of the contest entry to populate.

Tags
since
3.0.0
see
CB_Contests_Contest::get_contest()

save()

Save Save the contest to the database.

public save() : int|bool
Tags
since
3.0.0
access

public

see
CB_Contests_Contest::_insert()
Return values
int|bool

The ID of the contest if successful, false otherwise.

update()

Update Update contest entry in the database.

public static update([mixed $update_args = [] ][, mixed $where_args = [] ]) : int|WP_Error
Parameters
$update_args : mixed = []
$where_args : mixed = []
Tags
see
Confetti_Bits_Events_Contest::_update()
since
3.0.0
Return values
int|WP_Error

The number of rows updated, or WP_Error otherwise.

_delete()

Delete contest 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
3.0.0
access

protected

see
wpdb::delete()
see
CB_Contest_Contest::get_where_sql()
Return values
int|false

The number of rows updated, or false on error.

_insert()

_insert Insert contest entry into the database.

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

{ Associative array of contest data to insert, passed to wpdb::insert(). Accepts any key-value pair of a Confetti_Bits_Events_Contest object. }

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

{ See . Default [ '%d', '%d', '%d', '%d' ]. }

Tags
since
3.0.0
access

protected

see
wpdb::insert()
Return values
int|bool

The ID of the contest if successful, false otherwise.

_update()

Update contest 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 contest data to update, passed to . Accepts any property of a Confetti_Bits_Events_Contest 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
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

}

Tags
since
3.0.0
access

protected

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' => [
        'recipient_id' => 4,
    ),
    'format' => [
        '%d',
    ),
)

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()

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

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

{ Optional. Array of arguments for generating the WHERE SQL clause for get().

@type	int		$id	Contest ID.
@type	int		$recipient_id Recipient ID.
@type	int		$event_id Event ID.
@type	int		$placement Placement.
@type	int		$amount Amount.
@type	string	$date_created Date created.
@type	string	$date_modified Date modified.

}

Tags
since
3.0.0
access

protected

Return values
string

$where WHERE clause.


        
On this page

Search results