PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.41
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.41
5.5.84 5.5.83 5.5.82 5.5.81 5.5.80 5.5.79 5.5.77 5.5.76 5.5.75 5.5.73 5.5.72 5.5.22 5.5.23 5.5.29 5.5.3 5.5.31 5.5.32 5.5.34 5.5.35 5.5.36 5.5.37 5.5.4 5.5.40 5.5.41 5.5.42 All 160 releases
wp-data-access / WPDataAccess / Data_Dictionary / WPDA_List_Columns_Cache.php

WPDA_List_Columns_Cache.php in WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards 5.5.41, at WPDataAccess/Data_Dictionary/WPDA_List_Columns_Cache.php

53 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Suppress "error - 0 - No summary was found for this file" on phpdoc generation
5 *
6 * @package WPDataAccess\Data_Dictionary
7 */
8
9 namespace WPDataAccess\Data_Dictionary {
10
11 /**
12 * Class WPDA_List_Columns_Cache
13 *
14 * This class caches the instances of class {@see WPDA_List_Columns} used during the request to prevent repeating
15 * the same query more than once.
16 *
17 * @author Peter Schulz
18 * @since 1.0.0
19 *
20 * @see WPDA_List_Columns
21 */
22 class WPDA_List_Columns_Cache {
23
24 /**
25 * @var array Cached instances of WPDA_List_Columns
26 */
27 protected static $cached_list_columns = array();
28
29 /**
30 * Get instance of WPDA_List_Columns for supplied schema and table name
31 *
32 * Checks if an instance of class {@see WPDA_List_Columns} for the given combination of $schema_name and
33 * $table_name is already in cache. If an instance was found, a handle to it is returned. If not, a new
34 * instance is created, added to the cache and a handle to it is returned.
35 *
36 * @param $schema_name Database schema name (= MySQL database)
37 * @param $table_name Datable table name
38 *
39 * @return object Handle to instance of {@see WPDA_List_Columns} for supplied $schema_name and $table_name
40 */
41 public static function get_list_columns( $schema_name, $table_name ) {
42 $index = "$schema_name.$table_name";
43 if ( ! isset( self::$cached_list_columns[ $index ] ) ) {
44 self::$cached_list_columns[ $index ] = new WPDA_List_Columns( $schema_name, $table_name );
45 }
46
47 return self::$cached_list_columns[ $index ];
48 }
49
50 }
51
52 }
53