Advertisement
OptimatorX

WP Catalogue - db-settings.php

Jun 7th, 2013
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. <?php
  2.  
  3. //Create cat table
  4. function wpc_cat_table(){
  5. //Get the table name with the WP database prefix
  6. global $wpdb;
  7. $wpc_cat_table = $wpdb->prefix . "wpc_categories";
  8. $wpc_cat_table_version = "1.0";
  9. $installed_ver = get_option( "wpc_cat_table_version" );
  10. //Check if the table already exists and if the table is up to date, if not create it
  11. if($wpdb->get_var("SHOW TABLES LIKE '$wpc_cat_table'") != $wpc_cat_table
  12. || $installed_ver != $wpc_cat_table_version ) {
  13. $sql = "CREATE TABLE " . $wpc_cat_table . " (
  14. `id` INT( 9 ) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  15. `list_order` INT( 9 ) NOT NULL,
  16. `cat_name` VARCHAR( 255 ) NOT NULL,
  17. `cat_slug` VARCHAR( 255 ) NOT NULL,
  18. UNIQUE KEY id (id)
  19. );";
  20.  
  21. require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
  22. dbDelta($sql);
  23. update_option( "wpc_cat_table_version", $wpc_cat_table_version );
  24. }
  25. //Add database table versions to options
  26. add_option("wpc_cat_table_version", $wpc_cat_table_version);
  27. }
  28.  
  29. function wpc_product_table(){
  30. //Get the table name with the WP database prefix
  31. global $wpdb;
  32. $wpc_product_table = $wpdb->prefix . "wpc_products";
  33. $wpc_product_table_version = "1.0";
  34. $installed_ver = get_option( "wpc_product_table_version" );
  35. //Check if the table already exists and if the table is up to date, if not create it
  36. if($wpdb->get_var("SHOW TABLES LIKE '$wpc_cat_table'") != $wpc_product_table
  37. || $installed_ver != $wpc_product_table_version ) {
  38. $sql = "CREATE TABLE " . $wpc_product_table . " (
  39. `id` INT( 9 ) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  40. `list_order` INT( 9 ) NOT NULL,
  41. `product_title` TEXT NOT NULL,
  42. `product_desc` TEXT NOT NULL,
  43. `product_summary` TEXT NOT NULL,
  44. `product_featured` TEXT NOT NULL,
  45. `product_cats` TEXT NOT NULL,
  46. `product_img1` TEXT NOT NULL,
  47. `product_img2` TEXT NOT NULL,
  48. `product_img3` TEXT NOT NULL,
  49. `product_img4` TEXT NOT NULL,
  50. `product_img5` TEXT NOT NULL,
  51. `product_price` TEXT NOT NULL,
  52. `product_date` TEXT NOT NULL,
  53. UNIQUE KEY id (id)
  54. );";
  55.  
  56. require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
  57. dbDelta($sql);
  58. update_option( "wpc_product_table_version", $wpc_product_table_version );
  59. }
  60. //Add database table versions to options
  61. add_option("wpc_product_table_version", $wpc_product_table_version);
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement