CB_Transactions_Transaction
in package
CB Transactions Transaction
A component that allows users to send bits.
Tags
Table of Contents
Properties
- $amount : int
- The amount of Confetti Bits that were sent.
- $columns : mixed
- $component_action : int
- The component action associate with the Transaction.
- $component_name : int
- The component associated with the Transaction.
- $date_sent : int
- The date of the Transaction.
- $error : mixed
- $error_type : mixed
- $event_id : int
- The ID of the event associated with the Transaction.
- $id : int
- The Transaction ID.
- $item_id : int
- The item ID of the Transaction. Used with the BuddyBoss Notifications API. We'll use the sender_id.
- $last_inserted_id : int
- Last recorded Transaction ID in the database.
- $log_entry : int
- A memo for the Transaction.
- $recipient_id : int
- The ID of the user receiving the Confetti Bits.
- $secondary_item_id : int
- The secondary item ID of the Transaction. Used with the BuddyBoss Notifications API. We'll use the recipient_id.
- $sender_id : int
- The ID of the user sending the Confetti Bits.
Methods
- __construct() : mixed
- delete() : mixed
- Deletes a transaction entry from the database.
- get_activity_posts_for_user() : mixed
- get_date_query_sql() : mixed
- Assembles a date query clause for an SQL WHERE statement.
- get_orderby_sql() : string
- Get Orderby SQL.
- get_transactions() : array<string|int, mixed>
- Gets transactions from the database.
- get_users_balance() : mixed
- populate() : mixed
- Populates the object with data when passed a valid ID.
- save() : int|false
- Uses CB_Transactions_Transaction::_insert to plop a new transaction in the database.
- send_bits() : int|false
- Uses CB_Transactions_Transaction::_insert to plop a new transaction in the database.
- _delete() : int|false
- Deletes a transaction entry.
- _insert() : int
- Creates a new transaction in the database.
- 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
$amount
The amount of Confetti Bits that were sent.
public
int
$amount
$columns
public
static mixed
$columns
= array('id', 'item_id', 'secondary_item_id', 'sender_id', 'recipient_id', 'date_sent', 'log_entry', 'component_name', 'component_action', 'amount', 'event_id')
$component_action
The component action associate with the Transaction.
public
int
$component_action
$component_name
The component associated with the Transaction.
public
int
$component_name
$date_sent
The date of the Transaction.
public
int
$date_sent
$error
public
mixed
$error
$error_type
public
mixed
$error_type
= 'bool'
$event_id
The ID of the event associated with the Transaction.
public
int
$event_id
$id
The Transaction ID.
public
int
$id
$item_id
The item ID of the Transaction. Used with the BuddyBoss Notifications API. We'll use the sender_id.
public
int
$item_id
$last_inserted_id
Last recorded Transaction ID in the database.
public
static int
$last_inserted_id
$log_entry
A memo for the Transaction.
public
int
$log_entry
$recipient_id
The ID of the user receiving the Confetti Bits.
public
int
$recipient_id
$secondary_item_id
The secondary item ID of the Transaction. Used with the BuddyBoss Notifications API. We'll use the recipient_id.
public
int
$secondary_item_id
$sender_id
The ID of the user sending the Confetti Bits.
public
int
$sender_id
Methods
__construct()
public
__construct([mixed $id = 0 ]) : mixed
Parameters
- $id : mixed = 0
delete()
Deletes a transaction 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_activity_posts_for_user()
public
get_activity_posts_for_user([mixed $user_id = 0 ]) : mixed
Parameters
- $user_id : mixed = 0
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_transactions()
Gets transactions from the database.
public
get_transactions([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_Transaction::get_where_sql() @type array $orderby Array of specific key => value pairs that determine the ORDER BY clause. @see CB_Transactions_Transaction::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 transaction data.
get_users_balance()
public
get_users_balance([mixed $user_id = 0 ]) : mixed
Parameters
- $user_id : mixed = 0
populate()
Populates the object with data when passed a valid ID.
public
populate(int $id) : mixed
Parameters
- $id : int
-
A valid transaction ID.
save()
Uses CB_Transactions_Transaction::_insert to plop a new transaction in the database.
public
save() : int|false
Return values
int|false —The transaction ID on success, false on failure.
send_bits()
Uses CB_Transactions_Transaction::_insert to plop a new transaction in the database.
public
send_bits() : int|false
Return values
int|false —The transaction ID on success, false on failure.
_delete()
Deletes a transaction entry.
protected
static _delete([array<string|int, mixed> $where = array() ][, array<string|int, mixed> $where_format = array() ]) : int|false
Parameters
- $where : array<string|int, mixed> = array()
-
Array of WHERE clauses to filter by, passed to . Accepts any property of a CB_Transactions_Transaction object.
- $where_format : array<string|int, mixed> = array()
-
Tags
Return values
int|false —The number of rows updated, or false on error.
_insert()
Creates a new transaction in the database.
protected
static _insert([array<string|int, mixed> $data = [] ][, array<string|int, mixed> $data_format = [] ]) : int
All the parameters for this are handled by CB_Transactions_Transaction->send_bits().
Parameters
- $data : array<string|int, mixed> = []
-
{ An associative array of data to insert. Takes keys/values associated with a Transactions object. }
- $data_format : array<string|int, mixed> = []
-
{ A single-dimensional array of formats (i.e., '%s', '%d', etc.) Should match the same order of the data array. }
Return values
int —The number of rows inserted.
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_Participation_Participation::get_participation() 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() ]) : 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> = array()
-
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 transaction IDs. @type int $item_id One or more item IDs. @type int $secondary_item_id One or more secondary item IDs. @type int $sender_id One or more sender IDs. @type int $item_id One or more recipient IDs. @type string $log_entry Search terms that may be in a log_entry. @type string $component_name This will probably always be "confetti_bits". But we've added this just in case that ever changes. @type string $component_action A component action to search for.
}
Tags
Return values
string —The WHERE clause.