- Timestamp:
- May 19, 2011, 6:47:15 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Ver3.0/xpressme_integration_kit/include/onupdate.php
r590 r749 21 21 } 22 22 23 $db =& Database::getInstance() ;24 23 $mid = $module->getVar('mid') ; 25 24 … … 80 79 if( ! function_exists( 'xpress_put_siteurl' ) ) : 81 80 function xpress_put_siteurl($mydirname,$url){ 82 global $xoopsModule ;81 global $xoopsModule,$xoopsDB; 83 82 $wp_prefix = preg_replace('/wordpress/','wp',$mydirname); 84 $xoopsDB =& Database::getInstance();85 83 $db_xpress_option = $xoopsDB->prefix($wp_prefix . '_options'); 86 84 … … 92 90 if( ! function_exists( 'xpress_put_home' ) ) : 93 91 function xpress_put_home($mydirname,$url){ 94 global $xoopsModule ;92 global $xoopsModule,$xoopsDB; 95 93 $wp_prefix = preg_replace('/wordpress/','wp',$mydirname); 96 $xoopsDB =& Database::getInstance();97 94 $db_xpress_option = $xoopsDB->prefix($wp_prefix . '_options'); 98 95 … … 104 101 if( ! function_exists( 'get_xpress_option' ) ) { 105 102 function get_xpress_option($mydirname,$option_name){ 106 global $xoopsModule ;103 global $xoopsModule,$xoopsDB; 107 104 $wp_prefix = preg_replace('/wordpress/','wp',$mydirname); 108 $xoopsDB =& Database::getInstance();109 105 $option_table = $xoopsDB->prefix($wp_prefix . '_options'); 110 106 … … 135 131 if( ! function_exists( 'get_db_version' ) ) : 136 132 function get_db_version($mydirname){ 137 global $xoopsModule ;133 global $xoopsModule,$xoopsDB; 138 134 $wp_prefix = preg_replace('/wordpress/','wp',$mydirname); 139 $xoopsDB =& Database::getInstance();140 135 $db_xpress_option = $xoopsDB->prefix($wp_prefix . '_options'); 141 136 … … 180 175 function xpress_table_make($module, $mydirname) 181 176 { 182 $db =& Database::getInstance();177 global $xoopsDB; 183 178 $mid = $module->getVar('mid') ; 184 179 … … 195 190 KEY post_id (post_id) 196 191 ) TYPE=MyISAM"; 197 $ db->queryF( $queries ) ;192 $xoopsDB->queryF( $queries ) ; 198 193 $msgs[] = "$views_table table of XPressME was made."; 199 194 } else { 200 195 if (!is_found_table_column($views_table,'blog_id')){ 201 196 $queries ="ALTER TABLE $views_table ADD blog_id bigint(20) FIRST"; 202 $ db->queryF( $queries ) ;197 $xoopsDB->queryF( $queries ) ; 203 198 $msgs[] = "$views_table ADD blog_id ."; 204 199 } … … 206 201 // The table is repaired. 207 202 $non_blogid_sql ="SELECT * FROM $views_table WHERE blog_id IS NULL OR blog_id < 1"; 208 $non_blogid_res = $ db->query($non_blogid_sql, 0, 0);209 while($row = $ db->fetchArray($non_blogid_res)){203 $non_blogid_res = $xoopsDB->query($non_blogid_sql, 0, 0); 204 while($row = $xoopsDB->fetchArray($non_blogid_res)){ 210 205 $total_view = $row['post_views']; 211 206 $post_id = $row['post_id']; 212 207 $new_blogid_sql ="SELECT SUM(post_views) as post_views_sum FROM $views_table WHERE post_id = $post_id AND blog_id = 1 GROUP BY post_id"; 213 $new_blogid_res = $ db->query($new_blogid_sql, 0, 0);214 if ($ db->getRowsNum($new_blogid_res) > 0){215 $new_row = $ db->fetchArray($new_blogid_res);208 $new_blogid_res = $xoopsDB->query($new_blogid_sql, 0, 0); 209 if ($xoopsDB->getRowsNum($new_blogid_res) > 0){ 210 $new_row = $xoopsDB->fetchArray($new_blogid_res); 216 211 $total_view = $total_view + $new_row['post_views_sum']; 217 212 $del_sql = "DELETE FROM $views_table WHERE post_id = $post_id AND blog_id = 1"; 218 $ db->queryF( $del_sql ) ;213 $xoopsDB->queryF( $del_sql ) ; 219 214 } 220 215 $update_sql = "UPDATE $views_table SET post_views = $total_view , blog_id = 1 WHERE post_id = $post_id AND (blog_id IS NULL OR blog_id < 1)"; 221 $ db->queryF( $update_sql ) ;216 $xoopsDB->queryF( $update_sql ) ; 222 217 } 223 218 } … … 233 228 KEY post_id (post_id) 234 229 )TYPE=MyISAM"; 235 $ db->queryF( $queries ) ;230 $xoopsDB->queryF( $queries ) ; 236 231 $msgs[] = "$d3forum_link table of XPressME was made."; 237 232 } else { 238 233 if (!is_found_table_column($d3forum_link,'forum_id')){ 239 234 $queries ="ALTER TABLE $d3forum_link ADD forum_id bigint(20) unsigned NOT NULL default '0' AFTER wp_post_ID"; 240 $ db->queryF( $queries ) ;235 $xoopsDB->queryF( $queries ) ; 241 236 $msgs[] = "$d3forum_link ADD forum_id ."; 242 237 // The table is repaired. 243 238 // $update_sql = "UPDATE $d3forum_link SET forum_id = 1 WHERE(forum_id IS NULL OR forum_id < 1)"; 244 // $ db->queryF( $update_sql ) ;239 // $xoopsDB->queryF( $update_sql ) ; 245 240 } 246 241 if (!is_found_table_column($d3forum_link,'blog_id')){ 247 242 $queries ="ALTER TABLE $d3forum_link ADD blog_id bigint(20) unsigned NOT NULL default '0' AFTER forum_id"; 248 $ db->queryF( $queries ) ;243 $xoopsDB->queryF( $queries ) ; 249 244 $msgs[] = "$d3forum_link ADD blog_id ."; 250 245 // The table is repaired. 251 246 $update_sql = "UPDATE $d3forum_link SET blog_id = 1 WHERE(blog_id IS NULL OR blog_id < 1)"; 252 $ db->queryF( $update_sql ) ;247 $xoopsDB->queryF( $update_sql ) ; 253 248 } 254 249 } … … 266 261 KEY groupid (groupid) 267 262 )TYPE=MyISAM"; 268 $ db->queryF( $queries ) ;263 $xoopsDB->queryF( $queries ) ; 269 264 $sql = "INSERT INTO $group_role (groupid, role) VALUES (1, 'administrator')"; 270 $ db->queryF( $sql ) ;265 $xoopsDB->queryF( $sql ) ; 271 266 $msgs[] = "$group_role table of XPressME was made."; 272 267 } else { 273 268 if (!is_found_table_column($group_role,'blog_id')){ 274 269 $queries ="ALTER TABLE $group_role ADD blog_id bigint(20) AFTER groupid"; 275 $ db->queryF( $queries ) ;270 $xoopsDB->queryF( $queries ) ; 276 271 $msgs[] = "$group_role ADD blog_id ."; 277 272 } 278 273 // The table is repaired. 279 274 $update_sql = "UPDATE $group_role SET blog_id = 1 WHERE(blog_id IS NULL OR blog_id < 1)"; 280 $ db->queryF( $update_sql ) ;275 $xoopsDB->queryF( $update_sql ) ; 281 276 } 282 277 … … 295 290 KEY notify_reserve_id (notify_reserve_id) 296 291 )TYPE=MyISAM"; 297 $ db->queryF( $queries ) ;292 $xoopsDB->queryF( $queries ) ; 298 293 $msgs[] = "$notify_reserve table of XPressME was made."; 299 294 } … … 304 299 if( ! function_exists( 'enhanced_table_check' ) ) : 305 300 function enhanced_table_check($mydirname,$table_name){ 306 global $xoopsModule ;301 global $xoopsModule,$xoopsDB; 307 302 308 $xoopsDB =& Database::getInstance();309 303 $xpress_prefix = $xoopsDB->prefix(preg_replace('/wordpress/','wp',$mydirname) . '_'); 310 304 $db_enhanced = $xpress_prefix . $table_name; … … 325 319 if( ! function_exists( 'is_found_table_column' ) ) : 326 320 function is_found_table_column($table,$column){ 327 global $xoopsModule; 328 $xoopsDB =& Database::getInstance(); 321 global $xoopsModule,$xoopsDB; 329 322 330 323 $sql = "DESCRIBE $table $column";
Note: See TracChangeset
for help on using the changeset viewer.