1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Hook hit query class. |
5
|
|
|
* |
6
|
|
|
* @package wordpoints-hooks-api |
7
|
|
|
* @since 1.0.0 |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Runs queries on the hook hits database table. |
12
|
|
|
* |
13
|
|
|
* @since 1.0.0 |
14
|
|
|
*/ |
15
|
|
|
class WordPoints_Hook_Hit_Query extends WordPoints_DB_Query { |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @since 1.0.0 |
19
|
|
|
*/ |
20
|
|
|
protected $columns = array( |
21
|
|
|
'id' => array( 'format' => '%d', 'unsigned' => true ), |
22
|
|
|
'firer' => array( 'format' => '%s' ), |
23
|
|
|
'primary_arg_guid' => array( 'format' => '%s' ), |
24
|
|
|
'event' => array( 'format' => '%s' ), |
25
|
|
|
'reactor' => array( 'format' => '%s' ), |
26
|
|
|
'reaction_store' => array( 'format' => '%s' ), |
27
|
|
|
'reaction_context_id' => array( 'format' => '%s' ), |
28
|
|
|
'reaction_id' => array( 'format' => '%d', 'unsigned' => true ), |
29
|
|
|
'date' => array( 'format' => '%s', 'is_date' => true ), |
30
|
|
|
); |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @since 1.0.0 |
34
|
|
|
*/ |
35
|
|
|
protected $meta_type = 'wordpoints_hook_hit'; |
36
|
|
|
|
37
|
|
|
// |
38
|
|
|
// Public Methods. |
39
|
|
|
// |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Construct the class. |
43
|
|
|
* |
44
|
|
|
* All of the arguments are expected *not* to be SQL escaped. |
45
|
|
|
* |
46
|
|
|
* @since 1.0.0 |
47
|
|
|
* |
48
|
|
|
* @see WordPoints_DB_Query::$columns For a fuller explanation of the {column}, |
49
|
|
|
* {column}__in, {column}__not_in, and |
50
|
|
|
* {column}__compare args. |
51
|
|
|
* @see WP_Meta_Query for the proper arguments for 'meta_query', 'meta_key', |
52
|
|
|
* 'meta_value', 'meta_compare', and 'meta_type'. |
53
|
|
|
* @see WP_Date_Query for the proper arguments for 'date_query'. |
54
|
|
|
* |
55
|
|
|
* @param array $args { |
56
|
|
|
* The arguments for the query. |
57
|
|
|
* |
58
|
|
|
* @type string|array $fields Fields to include in the results. |
59
|
|
|
* @type int $id The ID of the hit to retrieve. |
60
|
|
|
* @type string $id__compare The comparison operator to use with the above value. |
61
|
|
|
* @type int[] $id__in A list of IDs to query for. |
62
|
|
|
* @type int[] $id__not_in A list of IDs to exclude. |
63
|
|
|
* @type string $firer The slug of the firer to query for. |
64
|
|
|
* @type string $firer__compare The comparison operator to use with the above value. |
65
|
|
|
* @type string[] $firer__in A list of firers to query for. |
66
|
|
|
* @type string[] $firer__not_in A list of firers to exclude. |
67
|
|
|
* @type string $primary_arg_guid The JSON encoded primary arg GUID to query for. |
68
|
|
|
* @type string $primary_arg_guid__compare The comparison operator to use with the above value. |
69
|
|
|
* @type string[] $primary_arg_guid__in A list of primary arg GUIDs to query for. |
70
|
|
|
* @type string[] $primary_arg_guid__not_in A list of primary arg GUIDs to exclude. |
71
|
|
|
* @type string $event The slug of the event to query for. |
72
|
|
|
* @type string $event__compare The comparison operator to use with the above value. |
73
|
|
|
* @type string[] $event__in A list of events to query for. |
74
|
|
|
* @type string[] $event__not_in A list of events to exclude. |
75
|
|
|
* @type string $reactor The slug of the reactor to query for. |
76
|
|
|
* @type string $reactor__compare The comparison operator to use with the above value. |
77
|
|
|
* @type string[] $reactor__in A list of reactors to query for. |
78
|
|
|
* @type string[] $reactor__not_in A list of reactors to exclude. |
79
|
|
|
* @type string $reaction_store The slug of the reaction store to query for. |
80
|
|
|
* @type string $reaction_store__compare The comparison operator to use with the above value. |
81
|
|
|
* @type string[] $reaction_store__in A list of reaction stores to query for. |
82
|
|
|
* @type string[] $reaction_store__not_in A list of reaction stores to exclude. |
83
|
|
|
* @type string $reaction_context_id The JSON encoded reaction context ID to query for. |
84
|
|
|
* @type string $reaction_context_id__compare The comparison operator to use with the above value. |
85
|
|
|
* @type string[] $reaction_context_id__in A list of reaction context IDs to query for. |
86
|
|
|
* @type string[] $reaction_context_id__not_in A list of reaction context IDs to exclude. |
87
|
|
|
* @type int $reaction_id The ID of the reaction to retrieve. |
88
|
|
|
* @type string $reaction_id__compare The comparison operator to use with the above value. |
89
|
|
|
* @type int[] $reaction_id__in A list of reaction IDs to query for. |
90
|
|
|
* @type int[] $reaction_id__not_in A list of reaction IDs to exclude. |
91
|
|
|
* @type array $date_query See WP_Date_Query |
92
|
|
|
* @type int $limit The maximum number of results to return. Default is null |
93
|
|
|
* (no limit). |
94
|
|
|
* @type int $start The start for the LIMIT clause. Default: 0. |
95
|
|
|
* @type string $order_by The field to use to order the results. Default: 'date'. |
96
|
|
|
* Supports 'meta_value'. |
97
|
|
|
* @type string $order The order for the query: ASC or DESC (default). |
98
|
|
|
* @type string $meta_key See WP_Meta_Query. |
99
|
|
|
* @type mixed $meta_value See WP_Meta_Query. |
100
|
|
|
* @type string $meta_compare See WP_Meta_Query. |
101
|
|
|
* @type string $meta_type See WP_Meta_Query. |
102
|
|
|
* @type array $meta_query See WP_Meta_Query. |
103
|
|
|
* } |
104
|
|
|
*/ |
105
|
|
|
public function __construct( $args = array() ) { |
106
|
|
|
|
107
|
|
|
global $wpdb; |
108
|
|
|
|
109
|
|
|
$this->table_name = $wpdb->wordpoints_hook_hits; |
110
|
|
|
|
111
|
|
|
$this->defaults['order_by'] = 'date'; |
112
|
|
|
|
113
|
|
|
parent::__construct( $args ); |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
// EOF |
118
|
|
|
|