wc_transaction_query

Run a MySQL transaction query, if supported.

Description

wc_transaction_query( (string) $type = 'start' ); 

Parameters (1)

0. $type — Optional. (string) => 'start'
Start (default), commit, rollback

Usage

  1. if ( !function_exists( 'wc_transaction_query' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-core-functions.php'; 
  3.  
  4. // start (default), commit, rollback 
  5. $type = 'start'; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_transaction_query($type); 
  9.  

Defined (1)

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

/includes/wc-core-functions.php  
  1. function wc_transaction_query( $type = 'start' ) { 
  2. global $wpdb; 
  3.  
  4. $wpdb->hide_errors(); 
  5.  
  6. if ( ! defined( 'WC_USE_TRANSACTIONS' ) ) { 
  7. define( 'WC_USE_TRANSACTIONS', true ); 
  8.  
  9. switch ( $type ) { 
  10. case 'commit' : 
  11. $wpdb->query( 'COMMIT' ); 
  12. break; 
  13. case 'rollback' : 
  14. $wpdb->query( 'ROLLBACK' ); 
  15. break; 
  16. default : 
  17. $wpdb->query( 'START TRANSACTION' ); 
  18. break;