PluginProbe
Educare – Students & Result Management System / 1.2.9
Educare – Students & Result Management System v1.2.9
trunk 1.0.0 1.0.1 1.0.2 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 All 30 releases
educare / includes / database / educare-database.php

educare-database.php in Educare – Students & Result Management System 1.2.9, at includes/database/educare-database.php

159 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Educare default settings
4 require_once(EDUCARE_INC.'database/default-settings.php');
5
6
7 /** =====================( Functions Details )======================
8
9 ### Check educare database version
10
11 * @since 1.2.0
12 * @last-update 1.2.4
13
14 * @return void
15
16 ===================( function for check database version )=================== **/
17
18 function educare_database_check($db) {
19 global $wpdb;
20 $table = $wpdb->prefix.$db;
21
22 // if database not exists
23 if ($wpdb->get_var("SHOW TABLES LIKE '$table'") != $table) {
24 // database not exists
25 return true;
26 } else {
27 // if database exists, and check (educare) database version
28 $info = educare_check_status('educare_info');
29 // if database version exists, that's mean our database version 1.2.0+ otherwise our database is old. (educare) old databse not support educare_info key.
30
31 if ($info) {
32
33 if ($db == 'educare_settings') {
34 $current_db = EDUCARE_SETTINGS_VERSION;
35 $istaled_db = $info->$db;
36
37 // if database db_version exists. check if our current (educare) database version 1.0+ or not. if is less then 1.0 then return TRUE. and create/insert our latest database
38 if (!($current_db <= $istaled_db)) {
39 return true;
40 }
41
42 }
43
44 } else {
45 // old (educare) database
46 return true;
47 }
48
49 }
50 }
51
52
53
54 /** =====================( Functions Details )======================
55
56 # Create educare database for store result and settings data
57
58 * @since 1.0.0
59 * @last-update 1.2.8
60
61 * @return void
62
63 ===================( function for educare database )=================== **/
64
65 // Create table for results system
66 function educare_database_table($db = null) {
67
68 global $wpdb;
69 $charset_collate = $wpdb->get_charset_collate();
70
71 // Create table for educare (plugins) settings
72 $Educare_settings = $wpdb->prefix."educare_settings";
73
74 $table1 = "CREATE TABLE $Educare_settings (
75 id int(11) NOT NULL AUTO_INCREMENT,
76 list varchar(255) NOT NULL,
77 data text NOT NULL,
78 PRIMARY KEY (id),
79 UNIQUE KEY list (list)
80 ) ENGINE=InnoDB DEFAULT CHARSET=latin1";
81
82 // Create table for educare results system
83 $Educare_results = $wpdb->prefix."educare_results";
84
85 $table2 = "CREATE TABLE $Educare_results (
86 id mediumint(11) NOT NULL AUTO_INCREMENT,
87 Name varchar(80) NOT NULL,
88 Roll_No varchar(80) NOT NULL,
89 Regi_No varchar(80) NOT NULL,
90 Class varchar(80) NOT NULL,
91 Exam varchar(80) NOT NULL,
92 Year varchar(80) NOT NULL,
93 Details longtext NOT NULL,
94 Subject longtext NOT NULL,
95 Result varchar(80),
96 GPA varchar(80),
97 PRIMARY KEY (id)
98 ) $charset_collate;";
99
100 // Create table for educare (plugins) settings
101 $Educare_students = $wpdb->prefix."educare_students";
102
103 $table3 = "CREATE TABLE $Educare_students (
104 id mediumint(11) NOT NULL AUTO_INCREMENT,
105 Name varchar(80) NOT NULL,
106 Roll_No varchar(80) NOT NULL,
107 Regi_No varchar(80) NOT NULL,
108 Class varchar(80) NOT NULL,
109 Year varchar(80) NOT NULL,
110 Details longtext NOT NULL,
111 Subject longtext NOT NULL,
112 Others longtext NOT NULL,
113 PRIMARY KEY (id)
114 ) $charset_collate;";
115
116 // Create table for educare (plugins) settings
117 $Educare_marks = $wpdb->prefix."educare_marks";
118
119 $table4 = "CREATE TABLE $Educare_marks (
120 id mediumint(11) NOT NULL AUTO_INCREMENT,
121 Class varchar(80) NOT NULL,
122 Exam varchar(80) NOT NULL,
123 Year varchar(80) NOT NULL,
124 Marks longtext NOT NULL,
125 Details longtext NOT NULL,
126 Status varchar(80) NOT NULL,
127 PRIMARY KEY (id)
128 ) $charset_collate;";
129
130
131 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
132
133 if ($db == 'educare_settings') {
134 dbDelta( $table1 );
135 }
136 elseif ($db == 'educare_results') {
137 dbDelta( $table2 );
138 }
139 elseif ($db == 'educare_students') {
140 dbDelta( $table3 );
141 }
142 elseif ($db == 'educare_marks') {
143 dbDelta( $table4 );
144 } else {
145 if (educare_database_check('educare_settings')) {
146 dbDelta( $table1 );
147 dbDelta( $table2 );
148 dbDelta( $table3 );
149 dbDelta( $table4 );
150 }
151 }
152
153 // Set educare default settings
154 educare_default_settings();
155
156 }
157
158
159 ?>