PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.4
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.4
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 5.5.43 All 159 releases
wp-data-access / WPDataAccess / Plugin_Table_Models / WPDP_Page_Model.php

WPDP_Page_Model.php in WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards 5.5.4, at WPDataAccess/Plugin_Table_Models/WPDP_Page_Model.php

88 lines 1.8 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\Plugin_Table_Models
7 */
8
9 namespace WPDataAccess\Plugin_Table_Models {
10
11 use WPDataAccess\WPDA;
12
13 /**
14 * Class WPDP_Page_Model
15 *
16 * Model for plugin table 'wpda_project_page'
17 *
18 * @author Peter Schulz
19 * @since 2.6.0
20 */
21 class WPDP_Page_Model extends WPDA_Plugin_Table_Base_Model {
22
23 const BASE_TABLE_NAME = 'wpda_project_page';
24
25 /**
26 * Method overwritten for different table name handling
27 *
28 * @return string Table name
29 */
30 public static function get_base_table_name() {
31 static::check_base_table_name();
32
33 global $wpdb;
34 return $wpdb->prefix . static::BASE_TABLE_NAME;
35 }
36
37 /**
38 * Get project page
39 *
40 * @param $project_id
41 * @param $page_id
42 *
43 * @return mixed
44 */
45 public static function get_page( $project_id, $page_id ) {
46 static::check_base_table_name();
47
48 global $wpdb;
49 return $wpdb->get_results(
50 $wpdb->prepare(
51 'select * from `%1s` where project_id = %d and page_id = %d', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
52 array(
53 WPDA::remove_backticks( static::get_base_table_name() ),
54 $project_id,
55 $page_id,
56 )
57 ),
58 'ARRAY_A'
59 ); // phpcs:ignore Standard.Category.SniffName.ErrorCode
60 }
61
62 /**
63 * Get project page
64 *
65 * @param $page_id
66 *
67 * @return mixed
68 */
69 public static function get_page_from_page_id( $page_id ) {
70 static::check_base_table_name();
71
72 global $wpdb;
73 return $wpdb->get_results(
74 $wpdb->prepare(
75 'select * from `%1s` where page_id = %d', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
76 array(
77 WPDA::remove_backticks( static::get_base_table_name() ),
78 $page_id,
79 )
80 ),
81 'ARRAY_A'
82 ); // phpcs:ignore Standard.Category.SniffName.ErrorCode
83 }
84
85 }
86
87 }
88