PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.84
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.84
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 / Plugin_Table_Models / WPDA_App_Apps_Model.php

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

103 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 namespace WPDataAccess\Plugin_Table_Models {
4
5 use WPDataAccess\WPDA;
6
7 class WPDA_App_Apps_Model extends WPDA_Plugin_Table_Base_Model {
8
9 const BASE_TABLE_NAME = 'wpda_app_apps';
10
11 public static function select_all( $app_id ) {
12
13 global $wpdb;
14 return $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
15 $wpdb->prepare(
16 'SELECT * FROM `%1s` WHERE app_id = %d order by seq_nr', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
17 array(
18 WPDA::remove_backticks( self::get_base_table_name() ),
19 $app_id,
20 )
21 ), // db call ok; no-cache ok.
22 'ARRAY_A'
23 ); // phpcs:ignore
24
25 }
26
27 public static function list() {
28
29 global $wpdb;
30 return $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
31 $wpdb->prepare('
32 SELECT *
33 FROM %i
34 ORDER BY app_id, seq_nr, app_id_detail
35 ',
36 array(
37 WPDA::remove_backticks( self::get_base_table_name() )
38 )
39 ),
40 'ARRAY_A'
41 );
42
43 }
44
45 public static function create(
46 $app_id,
47 $app_id_detail,
48 $seq_nr
49 ) {
50
51 global $wpdb;
52 if ( 1 === $wpdb->insert( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- plugin table
53 static::get_base_table_name(),
54 array(
55 'app_id' => $app_id,
56 'app_id_detail' => $app_id_detail,
57 'seq_nr' => $seq_nr,
58 )
59 )
60 ) {
61 return true;
62 } else {
63 return false;
64 }
65 }
66
67 public static function delete( $app_id, $delete_as_detail = false ) {
68
69 global $wpdb;
70
71 if ( $delete_as_detail ) {
72 $wpdb->delete( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
73 static::get_base_table_name(),
74 array(
75 'app_id_detail' => $app_id,
76 )
77 );
78 }
79
80 return $wpdb->delete( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
81 static::get_base_table_name(),
82 array(
83 'app_id' => $app_id,
84 )
85 );
86
87 }
88
89 public static function update(
90 $app_id,
91 $app_apps
92 ) {
93
94 self::delete( $app_id );
95 foreach ( $app_apps as $index => $app_detail_id ) {
96 self::create( $app_id, $app_detail_id, $index );
97 }
98
99 }
100
101 }
102
103 }