WC_PS_Product_SKU_Data

"Copyright 2012 A3 Revolution Web Design" This software is distributed under the terms of GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007.

Defined (1)

The class is defined in the following location(s).

/classes/data/class-wc-ps-product-sku-data.php  
  1. class WC_PS_Product_SKU_Data 
  2. public function install_database() { 
  3. global $wpdb; 
  4. $collate = ''; 
  5. if ( $wpdb->has_cap( 'collation' ) ) { 
  6. if( ! empty($wpdb->charset ) ) $collate .= "DEFAULT CHARACTER SET $wpdb->charset"; 
  7. if( ! empty($wpdb->collate ) ) $collate .= " COLLATE $wpdb->collate"; 
  8.  
  9. require_once ABSPATH . 'wp-admin/includes/upgrade.php'; 
  10.  
  11. $table_ps_product_sku = $wpdb->prefix. "ps_product_sku"; 
  12.  
  13. if ($wpdb->get_var("SHOW TABLES LIKE '$table_ps_product_sku'") != $table_ps_product_sku) { 
  14. $sql = "CREATE TABLE IF NOT EXISTS `{$table_ps_product_sku}` ( 
  15. post_id bigint(20) NOT NULL,  
  16. sku text NULL,  
  17. PRIMARY KEY (post_id) 
  18. ) $collate; "; 
  19.  
  20. $wpdb->query($sql); 
  21.  
  22.  
  23. /** 
  24. * Predictive Search Product SKU Table - set table name 
  25. * @return void 
  26. */ 
  27. public function set_table_wpdbfix() { 
  28. global $wpdb; 
  29. $meta_name = 'ps_product_sku'; 
  30.  
  31. $wpdb->ps_product_sku = $wpdb->prefix . $meta_name; 
  32.  
  33. $wpdb->tables[] = 'ps_product_sku'; 
  34.  
  35. /** 
  36. * Insert Predictive Search Product SKU 
  37. */ 
  38. public function insert_item( $post_id, $sku = '' ) { 
  39. global $wpdb; 
  40. return $wpdb->query( $wpdb->prepare( "INSERT INTO {$wpdb->ps_product_sku} VALUES(%d, %s)", $post_id, stripslashes( $sku ) ) ); 
  41.  
  42. /** 
  43. * Update Predictive Search Product SKU 
  44. */ 
  45. public function update_item( $post_id, $sku = '' ) { 
  46. global $wpdb; 
  47.  
  48. $value = $this->get_item( $post_id ); 
  49. if ( NULL == $value ) { 
  50. return $this->insert_item( $post_id, $sku ); 
  51. } else { 
  52. return $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->ps_product_sku} SET sku = %s WHERE post_id = %d ", stripslashes( $sku ), $post_id ) ); 
  53.  
  54. /** 
  55. * Get Predictive Search Product SKU 
  56. */ 
  57. public function get_item( $post_id ) { 
  58. global $wpdb; 
  59. return $wpdb->get_var( $wpdb->prepare( "SELECT sku FROM {$wpdb->ps_product_sku} WHERE post_id = %d LIMIT 0, 1 ", $post_id ) ); 
  60.  
  61. /** 
  62. * Delete Predictive Search Product SKU 
  63. */ 
  64. public function delete_item( $post_id ) { 
  65. global $wpdb; 
  66. return $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->ps_product_sku} WHERE post_id = %d ", $post_id ) ); 
  67.  
  68. /** 
  69. * Empty Predictive Search Product SKU 
  70. */ 
  71. public function empty_table() { 
  72. global $wpdb; 
  73. return $wpdb->query( "TRUNCATE {$wpdb->ps_product_sku}" );