PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.17.0
GiveWP – Donation Plugin and Fundraising Platform v2.17.0
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
give / src / Helpers / Table.php
Table.php
70 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Helpers;
4
5 /**
6 * Class Table
7 * @package Give\Helpers
8 *
9 * @since 2.9.0
10 */
11 class Table {
12 /**
13 * Get table name.
14 *
15 * @since 2.9.0
16 *
17 * @param $tableName
18 *
19 * @return string
20 */
21 public static function prefixTableName( $tableName ) {
22 global $wpdb;
23
24 return "{$wpdb->prefix}{$tableName}";
25 }
26
27 /**
28 * Check if the given table exists
29 *
30 * @since 2.9.0
31 * @access public
32 *
33 * @param $tableName
34 *
35 * @return bool If the table name exists.
36 */
37 public static function tableExists( $tableName ) {
38 global $wpdb;
39
40 return (bool) $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $tableName ) );
41 }
42
43 /**
44 * Checks whether column exists in a table or not.
45 *
46 * @since 2.9.0
47 *
48 * @param $columnName
49 * @param $tableName
50 *
51 * @return bool
52 */
53 public static function doesColumnExist( $tableName, $columnName ) {
54 global $wpdb;
55
56 return (bool) $wpdb->get_results(
57 $wpdb->prepare(
58 'SELECT * FROM INFORMATION_SCHEMA.COLUMNS
59 WHERE TABLE_SCHEMA = %s
60 AND TABLE_NAME = %s
61 AND COLUMN_NAME = %s ',
62 DB_NAME,
63 $tableName,
64 $columnName
65 )
66 );
67 }
68 }
69
70