PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.7.0.7
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.7.0.7
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 1.7.0.9 All 211 releases
charitable / includes / data / class-charitable-donormeta-db.php

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

130 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Charitable Donormeta DB class.
4 *
5 * @package Charitable/Classes/Charitable_Donormeta_DB
6 * @author David Bisset
7 * @copyright Copyright (c) 2022, WP Charitable LLC
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 1.6.0
10 * @version 1.6.0
11 */
12
13 // Exit if accessed directly.
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 if ( ! class_exists( 'Charitable_Donormeta_DB' ) ) :
19
20 /**
21 * Charitable_Donormeta_DB
22 *
23 * @since 1.6.0
24 */
25 class Charitable_Donormeta_DB extends Charitable_DB {
26
27 /**
28 * The version of our database table
29 *
30 * @since 1.6.0
31 *
32 * @var string
33 */
34 public $version = '1.6.0';
35
36 /**
37 * The name of the primary column
38 *
39 * @since 1.6.0
40 *
41 * @var string
42 */
43 public $primary_key = 'meta_id';
44
45 /**
46 * Set up the database table name.
47 *
48 * @since 1.6.0
49 *
50 * @global WPDB $wpdb
51 */
52 public function __construct() {
53 global $wpdb;
54
55 $this->table_name = $wpdb->prefix . 'charitable_donormeta';
56 }
57
58 /**
59 * Create the table.
60 *
61 * @since 1.6.0
62 *
63 * @global WPDB $wpdb
64 */
65 public function create_table() {
66 global $wpdb;
67
68 $charset_collate = $wpdb->get_charset_collate();
69
70 $sql = "CREATE TABLE {$this->table_name} (
71 meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
72 donor_id bigint(20) unsigned NOT NULL DEFAULT '0',
73 meta_key varchar(255) DEFAULT NULL,
74 meta_value longtext,
75 PRIMARY KEY (meta_id),
76 KEY donor_id (donor_id),
77 KEY meta_key (meta_key(191))
78 ) $charset_collate;";
79
80 $this->_create_table( $sql );
81 }
82
83 /**
84 * Whitelist of columns.
85 *
86 * @since 1.6.0
87 *
88 * @return array
89 */
90 public function get_columns() {
91 return array(
92 'meta_id' => '%d',
93 'donor_id' => '%d',
94 'meta_key' => '%s',
95 'meta_value' => '%s',
96 );
97 }
98
99 /**
100 * Default column values.
101 *
102 * @since 1.6.0
103 *
104 * @return array
105 */
106 public function get_column_defaults() {
107 return array(
108 'meta_id' => '',
109 'donor_id' => 0,
110 'meta_key' => '',
111 'meta_value' => '',
112 );
113 }
114
115 /**
116 * Add a new donor meta item.
117 *
118 * @since 1.6.0
119 *
120 * @param array $data Donor data to insert.
121 * @param string $type Should always be 'donormeta'.
122 * @return int The ID of the inserted donor.
123 */
124 public function insert( $data, $type = 'donormeta' ) {
125 return parent::insert( $data, $type );
126 }
127 }
128
129 endif;
130