CB_Transactions_Spot_Bonus
in package
A component that allows certain users to schedule spot bonuses.
Tags
Table of Contents
Properties
- $columns : mixed
- $id : int
- The Transaction ID.
- $last_inserted_id : int
- Last recorded Transaction ID in the database.
- $recipient_id : int
- The ID of the user receiving the Confetti Bits.
- $sender_id : int
- The ID of the user sending the Confetti Bits.
- $spot_bonus_date : datetime
- The date of the spot bonus.
- $transaction_id : int
- The ID of the associated transaction.
Methods
- __construct() : mixed
- delete() : mixed
- Deletes a spot bonus entry from the database.
- get_date_query_sql() : mixed
- Assembles a date query clause for an SQL WHERE statement.
- get_orderby_sql() : string
- Get Orderby SQL.
- get_spot_bonuses() : array<string|int, mixed>
- Gets spot bonuses from the database.
- populate() : mixed
- Populates a spot bonus object with data when given an ID.
- save() : mixed
- Saves a spot bonus entry to the database.
- update() : int|WP_Error
- Update spot bonus entry in the database.
- _delete() : int|false
- Deletes a spot bonus entry.
- _insert() : mixed
- Inserts a spot bonus into the database.
- _update() : int|false
- Update spot bonus 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
- Assembles the SQL WHERE clause.
Properties
$columns
public
static mixed
$columns
= array('id', 'sender_id', 'recipient_id', 'spot_bonus_date', 'transaction_id')
$id
The Transaction ID.
public
int
$id
$last_inserted_id
Last recorded Transaction ID in the database.
public
static int
$last_inserted_id
$recipient_id
The ID of the user receiving the Confetti Bits.
public
int
$recipient_id
$sender_id
The ID of the user sending the Confetti Bits.
public
int
$sender_id
$spot_bonus_date
The date of the spot bonus.
public
datetime
$spot_bonus_date
$transaction_id
The ID of the associated transaction.
public
int
$transaction_id
Methods
__construct()
public
__construct([mixed $id = 0 ]) : mixed
Parameters
- $id : mixed = 0
delete()
Deletes a spot bonus entry from the database.
public
delete([array<string|int, mixed> $args = [] ]) : mixed
Parameters
- $args : array<string|int, mixed> = []
-
An associative array of arguments that gets passed to self::get_query_clauses for formatting. Accepts any property of a CB_Transactions_Transaction object. For example: ['recipient_id' => 4, 'sender_id' => 16]
Tags
get_date_query_sql()
Assembles a date query clause for an SQL WHERE statement.
public
static get_date_query_sql([mixed $date_query = array() ]) : mixed
Parameters
- $date_query : mixed = array()
Tags
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.
get_spot_bonuses()
Gets spot bonuses from the database.
public
get_spot_bonuses([array<string|int, mixed> $args = [] ]) : array<string|int, mixed>
Pieces together an SQL query based on the given arguments.
Parameters
- $args : array<string|int, mixed> = []
-
{ Optional. An array of arguments that get merged with some defaults.
@type string|array $select Default '*'. Either a comma-separated list or array of the columns to select. @type array $where Array of key => value pairs that get passed to an internal method. @see CB_Transactions_Spot_Bonus::get_where_sql() @type array $orderby Array of specific key => value pairs that determine the ORDER BY clause. @see CB_Transactions_Spot_Bonus::get_orderby_sql() @type string $groupby A string that determines whether the query should be grouped by a specific column. @type array $pagination An array of specific key => value pairs that determine the LIMIT clause. }
Tags
Return values
array<string|int, mixed> —An associative array of spot bonus data.
populate()
Populates a spot bonus object with data when given an ID.
public
populate(int $id) : mixed
Parameters
- $id : int
-
The ID of the spot bonus to fetch.
save()
Saves a spot bonus entry to the database.
public
save() : mixed
update()
Update spot bonus entry in the database.
public
static update([mixed $update_args = [] ][, mixed $where_args = [] ]) : int|WP_Error
Parameters
- $update_args : mixed = []
- $where_args : mixed = []
Tags
Return values
int|WP_Error —The number of rows updated, or WP_Error otherwise.
_delete()
Deletes a spot bonus entry.
protected
static _delete([array<string|int, mixed> $where = [] ][, array<string|int, mixed> $where_format = [] ]) : int|false
Parameters
- $where : array<string|int, mixed> = []
-
Array of WHERE clauses to filter by, passed to . Accepts any property of a CB_Transactions_Transaction object.
- $where_format : array<string|int, mixed> = []
-
Tags
Return values
int|false —The number of rows updated, or false on error.
_insert()
Inserts a spot bonus into the database.
protected
static _insert([mixed $data = [] ][, mixed $data_format = [] ]) : mixed
Parameters
- $data : mixed = []
- $data_format : mixed = []
_update()
Update spot bonus 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 CB_Transactions_Spot_Bonus 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> = []
-
- $where_format : array<string|int, mixed> = []
-
Tags
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 = array() ]) : string
Used by CB_Transactions_Spot_Bonus::get_spot_bonuses() to create its LIMIT clause.
Parameters
- $args : array<string|int, mixed> = array()
-
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, array( '%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 = array(
'applicant_id' => 4,
'component_action' => 'cb_participation_new'
);
This will be converted to:
array(
'data' => array(
'applicant_id' => 4,
'component_action' => 'cb_participation_new',
),
'format' => array(
'%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()
Assembles the SQL WHERE clause.
protected
static get_where_sql([array<string|int, mixed> $args = [] ]) : string
Parameters
- $args : array<string|int, mixed> = []
-
{ An associative array of arguments. All optional.
@type int $id One or more spot bonus IDs. @type int $sender_id One or more sender IDs. @type string $date_query A date query to send to CB_Transactions_Spot_Bonus::get_date_query_sql
}
Tags
Return values
string —The WHERE clause.