Confetti Bits

CB_Requests_Request
in package

A component that allows users to submit requests to cash in their points.

Tags
since
2.3.0

Table of Contents

Properties

$admin_id  : int
The ID of the admin associated with the entry.
$applicant_id  : int
The ID of the user associated with the entry.
$columns  : array<string|int, mixed>
The columns available in the database. Used to help build our orderby clause.
$component_action  : string
The component action associated with the entry.
$component_name  : string
The component associated with the entry.
$date_created  : string
The date the entry was created.
$date_modified  : string
The date of the last time the entry was modified.
$id  : int
The ID of the requests entry.
$item_id  : int
The ID of the main item or user associated with the requests entry.
$request_item_id  : int
The request_item_id assigned to the the entry.
$secondary_item_id  : int
The ID of the secondary item associated with the requests entry.
$status  : string
The last updated status of the entry.

Methods

__construct()  : mixed
Constructor.
delete()  : int|false
Deletes rows from the database.
get_date_query_sql()  : string
Assembles a date query into SQL for use in a WHERE clause.
get_orderby_sql()  : string
Get Orderby SQL
get_requests()  : mixed
get_requests
populate()  : mixed
Populate
save()  : obj|int
Save
update()  : int|false
Update status entry.
_delete()  : int|false
Delete requests entry.
_insert()  : int|bool
_insert
_update()  : int|false
Update requests 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

$columns

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

public static array<string|int, mixed> $columns = ['id', 'item_id', 'secondary_item_id', 'applicant_id', 'admin_id', 'date_created', 'date_modified', 'component_name', 'component_action', 'status', 'request_item_id']

$component_action

The component action associated with the entry.

public string $component_action

Used for BuddyBoss's Notifications API.

$component_name

The component associated with the entry.

public string $component_name

Used for BuddyBoss's Notifications API.

$item_id

The ID of the main item or user associated with the requests entry.

public int $item_id

We usually use the applicant_id for this. Used for BuddyBoss's Notifications API.

$request_item_id

The request_item_id assigned to the the entry.

public int $request_item_id

Updated after a request has been created, to allow the request to be tied to a specific request item.

$secondary_item_id

The ID of the secondary item associated with the requests entry.

public int $secondary_item_id

We usually use the admin_id for this. Used for BuddyBoss's Notifications API.

Methods

delete()

Deletes rows from the database.

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

Careful there, bucko. It's dangerous round these parts.

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

An array of key-value pairs that gets passed to self::get_query_clauses()

Tags
since
2.3.0
Return values
int|false

The number of rows affected, or false on failure.

get_date_query_sql()

Assembles a date query into SQL for use in a WHERE clause.

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

An array of date query clauses.

Tags
see
WP_Date_Query
since
2.3.0
Return values
string

The SQL WHERE clause for the query.

get_orderby_sql()

Get Orderby SQL

public static get_orderby_sql([mixed $args = [] ]) : string

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

Parameters
$args : mixed = []
Return values
string

The ORDER BY clause of an SQL query.

get_requests()

get_requests

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

Handles retrieving data from the database. Nice and clean!

Parameters
$args : array<string|int, mixed> = array()

An array of stuff to get! { @type string $select The database column to get @type array $where A selection of key-value pairs that get evaluated by another method. See self::get_where_sql()

Tags
TODO:

Finish documenting this (sweat emoji) }

populate()

Populate

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

Populates object data associated with the given ID.

Parameters
$id : int = 0

The requests ID.

save()

Save

public save() : obj|int

Handles saving data to the database using our static _insert method.

Return values
obj|int

WP_Error on failure, requests ID on success.

update()

Update status entry.

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

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

$where_args : array<string|int, mixed> = array()

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

Return values
int|false

Number of rows updated on success, false on failure.

_delete()

Delete requests 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_Requests_Requests object.

$where_format : array<string|int, mixed> = array()

See .

Tags
see
wpdb::update()

for further description of paramater formats.

Return values
int|false

The number of rows updated, or false on error.

_insert()

_insert

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

Handles the actual insertion into the database.

Parameters
$data : mixed = array()
$data_format : mixed = array()
Return values
int|bool

The inserted ID on success, false on failure.

_update()

Update requests entry.

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

Array of requests data to update, passed to . Accepts any property of a Confetti_Bits_Requests_Requests object.

$where : array<string|int, mixed> = array()

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

$data_format : array<string|int, mixed> = array()

See .

$where_format : array<string|int, mixed> = array()

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 = array() ]) : string

Used by CB_Requests_Requests::get_requests() 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_requests_new'
);

This will be converted to:

array(
    'data' => array(
        'applicant_id' => 4,

            'component_action' => 'cb_requests_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()

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

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

Used by CB_Requests_Requests::get_requests() to create its WHERE clause.

Parameters
$args : array<string|int, mixed> = array()

{ Optional array of arguments.

@type	int		$id				One or more request IDs.
@type	int		$applicant_id	One or more applicant IDs.
@type	int		$admin_id		One or more admin IDs.
@type	string	$status			One or more request statuses.
@type	string $component_name	One or more component names.
@type	string $component_action	One or more component actions.
@type    request_item_id	One or more request item IDs.
@type    item_id	One or more item IDs.
@type    secondary_item_id	One or more secondary item IDs.
@type    string $date_query	A date query to restrict the result set by.

}

Tags
since
2.3.0
Return values
string

$retval WHERE clause.


        
On this page

Search results