PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 1.1.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v1.1.1
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
bit-form / includes / Core / Database / ApiModel.php

ApiModel.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 1.1.1, at includes/Core/Database/ApiModel.php

121 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Core\Database;
4
5 use BitCode\BitForm\Core\Database\Model;
6 use BitCode\BitForm\Core\Util\IpTool;
7
8 /**
9 * Undocumented class
10 */
11
12 class ApiModel extends Model
13 {
14 public function __construct()
15 {
16 global $wpdb;
17 $this->_wpdb = $wpdb;
18 }
19 public function getForm()
20 {
21
22 $result = $this->_wpdb->get_results(
23 "
24 SELECT form_name,id FROM `{$this->_wpdb->prefix}bitforms_form` WHERE `status`=1 order By created_at DESC
25 "
26 );
27 return $result;
28 }
29
30 public function getField($id)
31 {
32 $result = $this->_wpdb->get_results(
33 "
34 SELECT form_content,id FROM `{$this->_wpdb->prefix}bitforms_form` WHERE `status`=1 AND `id`='$id'
35 "
36 );
37 return $result;
38 }
39
40 public function editEntry($entryID)
41 {
42 $result = $this->_wpdb->get_results(
43 "
44 SELECT bitforms_form_entry_id,meta_key,meta_value FROM `{$this->_wpdb->prefix}bitforms_form_entrymeta` WHERE `bitforms_form_entry_id`='$entryID'
45 "
46 );
47 return $result;
48 }
49
50 public function entryDelete( $entryID )
51 {
52 $sql = "DELETE FROM `{$this->_wpdb->prefix}bitforms_form_entrymeta` WHERE `id` = $entryID";
53 $result = $this->_wpdb->query($sql);
54 return $result;
55 }
56
57 public function findRecord($table_name, $column, $value)
58 {
59
60 $result = $this->_wpdb->get_results(
61 "
62 SELECT $column FROM `{$this->_wpdb->prefix}$table_name` WHERE `$column`='$value'
63 "
64 );
65 return $result;
66 }
67
68 public function noteCreate($formID, $entryID, $note_details)
69 {
70
71 $ipTool = new IpTool();
72 $user_details = $ipTool->getUserDetail();
73
74 $result = $this->_wpdb->insert(
75 "{$this->_wpdb->prefix}bitforms_form_entry_relatedinfo",
76 array(
77 'info_type' => 'note',
78 'info_details' => $note_details,
79 'form_id' => $formID,
80 'entry_id' => $entryID,
81 'user_id' => $user_details['id'],
82 'user_ip' => $user_details['ip'],
83 'created_at' => $user_details['time'],
84 )
85 );
86 return $result;
87 }
88
89 public function noteList()
90 {
91 $result = $this->_wpdb->get_results(
92 "
93 SELECT * FROM `{$this->_wpdb->prefix}bitforms_form_entry_relatedinfo` WHERE `status`=1
94 "
95 );
96 return $result;
97 }
98
99 public function noteUpdate($noteID, $note_details)
100 {
101 $data = array(
102 'info_details' => $note_details,
103 );
104 $result = $this->_wpdb->update(
105 "{$this->_wpdb->prefix}bitforms_form_entry_relatedinfo",
106 $data,
107 array(
108 'id' => $noteID,
109 )
110 );
111 return $result;
112 }
113
114 public function noteDelete($noteID)
115 {
116 $sql = "DELETE FROM `{$this->_wpdb->prefix}bitforms_form_entry_relatedinfo` WHERE `id` = $noteID";
117 $result = $this->_wpdb->query($sql);
118 return $result;
119 }
120 }
121