PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.12.2
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.12.2
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / includes / data / class-charitable-campaign-activities-db.php

class-charitable-campaign-activities-db.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.12.2, at includes/data/class-charitable-campaign-activities-db.php

220 lines 4.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Charitable Campaign Activities DB class.
4 *
5 * @package Charitable/Classes/Charitable_Campaign_Activities_DB
6 * @version 1.8.1
7 * @author David Bisset
8 * @copyright Copyright (c) 2023, WP Charitable LLC
9 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 if ( ! class_exists( 'Charitable_Campaign_Activities_DB' ) ) :
18
19 /**
20 * Charitable_Campaign_Activities_DB
21 *
22 * @since 1.8.1
23 */
24 class Charitable_Campaign_Activities_DB extends Charitable_DB {
25
26 /**
27 * The single instance of this class.
28 *
29 * @var Charitable_Campaign_Activities_DB|null
30 */
31 private static $instance = null;
32
33 /**
34 * The version of our database table
35 *
36 * @since 1.8.1
37 * @var string
38 */
39 public $version = '1.8.1';
40
41 /**
42 * The name of the primary column
43 *
44 * @since 1.8.1
45 * @var string
46 */
47 public $primary_key = 'activity_id';
48
49 /**
50 * The name of the table.
51 *
52 * @since 1.8.1
53 * @var string
54 */
55 public $table_name = 'charitable_campaign_activities';
56
57 /**
58 * Set up the database table name.
59 *
60 * @since 1.8.1
61 */
62 public function __construct() {
63 global $wpdb;
64
65 $this->table_name = $wpdb->prefix . 'charitable_campaign_activities';
66 }
67
68 /**
69 * Create the table.
70 *
71 * @global $wpdb
72 * @since 1.8.1
73 */
74 public function create_table() {
75 global $wpdb;
76
77 $charset_collate = $wpdb->get_charset_collate();
78
79 $sql = "CREATE TABLE IF NOT EXISTS {$this->table_name} (
80 `activity_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
81 `campaign_id` int(11) unsigned DEFAULT NULL,
82 `type` varchar(25) DEFAULT NULL,
83 `primary_action` varchar(25) DEFAULT NULL,
84 `secondary_action` varchar(25) DEFAULT NULL,
85 `created_by` int(11) DEFAULT NULL,
86 `date_recorded` datetime DEFAULT NULL,
87 PRIMARY KEY (`activity_id`)
88 ) $charset_collate;";
89
90 $this->_create_table( $sql );
91 }
92
93
94 /**
95 * Checks if the table exists.
96 *
97 * @global $wpdb
98 * @since 1.8.1
99 */
100 public function table_exists() {
101 global $wpdb;
102
103 return $wpdb->get_var( "SHOW TABLES LIKE '{$this->table_name}'" ) === $this->table_name; // phpcs:ignore
104 }
105
106 /**
107 * Remove the table.
108 *
109 * @global $wpdb
110 * @since 1.8.1
111 *
112 * @return void
113 */
114 public function remove_table() {
115 global $wpdb;
116
117 $sql = "DROP TABLE IF EXISTS {$this->table_name};";
118
119 $wpdb->query( $sql ); // phpcs:ignore
120 }
121
122 /**
123 * Wipes all data from the table.
124 *
125 * @global $wpdb
126 * @since 1.8.1
127 *
128 * @return void
129 */
130 public function clear_table() {
131 global $wpdb;
132
133 $sql = "TRUNCATE TABLE {$this->table_name};";
134
135 $wpdb->query( $sql ); // phpcs:ignore
136 }
137
138 /**
139 * Whitelist of columns.
140 *
141 * @since 1.8.1
142 *
143 * @return array
144 */
145 public function get_columns() {
146 return array(
147 'activity_id' => '%d',
148 'campaign_id' => '%d',
149 'type' => '%s',
150 'primary_action' => '%s',
151 'secondary_action' => '%s',
152 'created_by' => '%d',
153 'date_recorded' => '%s',
154 );
155 }
156
157 /**
158 * Default column values.
159 *
160 * @since 1.8.1
161 *
162 * @return array
163 */
164 public function get_column_defaults() {
165 return array(
166 'date_recorded' => gmdate( 'Y-m-d H:i:s' ),
167 );
168 }
169
170 /**
171 * Add a new object. Currently a placeholder function for future use.
172 *
173 * @since 1.8.1
174 *
175 * @param array $data Data to insert.
176 * @param string $type Optional. Type of data to insert. Default is empty string.
177 */
178 public function insert( $data, $type = '' ) {
179 }
180
181 /**
182 * Update a object. Currently a placeholder function for future use.
183 *
184 * @since 1.8.1
185 *
186 * @param int $row_id The row ID.
187 * @param array $data Optional.
188 * @param array $where Optional.
189 */
190 public function update( $row_id, $data = array(), $where = '' ) {
191 }
192
193 /**
194 * Delete a row identified by the primary key. Currently a placeholder function for future use.
195 *
196 * @since 1.8.1
197 *
198 * @param int $row_id The row ID.
199 */
200 public function delete( $row_id = 0 ) {
201 }
202
203 /**
204 * Returns and/or create the single instance of this class.
205 *
206 * @since 1.8.1
207 *
208 * @return Charitable_Campaign_Activities_DB
209 */
210 public static function get_instance() {
211 if ( is_null( self::$instance ) ) {
212 self::$instance = new self();
213 }
214
215 return self::$instance;
216 }
217 }
218
219 endif;
220