PluginProbe
Float menu – awesome floating side menu / 3.3.1
Float menu – awesome floating side menu v3.3.1
7.2.5 trunk 2.1 2.2 3.0.1 3.1 3.2.2 3.3.1 3.5 3.5.1 3.5.2 3.5.3. 3.5.4 4.0 4.1 4.1.1 4.2 4.3 4.3.1 4.3.2 5.0 5.0.1 5.0.2 5.0.3 5.1 All 57 releases
float-menu / includes / class-db.php

class-db.php in Float menu – awesome floating side menu 3.3.1, at includes/class-db.php

80 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * DataBase Update
4 *
5 * @package Wow_Plugin
6 * @subpackage Includes/Database
7 * @author Dmytro Lobov <i@lobov.dev>
8 * @copyright 2019 Wow-Company
9 * @license GNU Public License
10 * @version 2.0
11
12 */
13
14 namespace float_menu_free;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20 /**
21 * Creates and updates a record in the database
22 *
23 * @since 1.0
24 *
25 * @property string plugin_dir - filesystem directory path for the plugin
26 * @property string basedir - URL to the file which saving CSS and JS files
27 */
28 class Wow_DB_Update {
29
30 /**
31 * Create a new Item in the database
32 *
33 * @param string $table name of the datatable
34 * @param string $info array of parameters to save to the database
35 *
36 * @since 1.0
37 */
38 function create_item( $table, $info ) {
39 global $wpdb;
40 $fields = $wpdb->get_col( "DESC " . $table, 0 );
41 // Collect all passed parameters
42 $data = array();
43 foreach ( $fields as $key ) {
44 if ( is_array( $info[ $key ] ) == true ) {
45 $data[ $key ] = serialize( $info[ $key ] );
46 } else {
47 $data[ $key ] = $info[ $key ];
48 }
49 }
50 // Insert in database
51 $wpdb->insert( $table, $data );
52 }
53
54 /**
55 * Update an existing item in the database
56 *
57 * @param string $table name of the datatable
58 * @param string $info array of parameters to save to the database
59 *
60 * @since 1.0
61 */
62 function update_item( $table, $info ) {
63 global $wpdb;
64 $fields = $wpdb->get_col( "DESC " . $table, 0 );
65 // Collect all passed parameters
66 $data = array();
67 foreach ( $fields as $key ) {
68 if ( is_array( $info[ $key ] ) == true ) {
69 $data[ $key ] = serialize( $info[ $key ] );
70 } else {
71 $data[ $key ] = $info[ $key ];
72 }
73 }
74
75 $id = absint( $info["id"] );
76 $wpdb->update( $table, $data, array( 'id' => $id ), $format = null, $where_format = null );
77
78 }
79 }
80