Answers for "Db commit wordpress"

0

Db commit wordpress

try {
  $wpdb->query('START TRANSACTION');
  $result1 = $wpdb->delete( $table, $where, $where_format = null );
  $resul2 = $wpdb->delete( $table, $where, $where_format = null );

  if (! $result) {
    throw new Exception('db error');
  }

  if ($result1 && $result2) {
      $wpdb->query('COMMIT'); // if you come here then well done
  } else {
      $wpdb->query('ROLLBACK'); // // something went wrong, Rollback
  }
} catch(Exception $e) {
	$wpdb->query('ROLLBACK');
	return $e->message();
}
Posted by: Guest on August-03-2021

Browse Popular Code Answers by Language