Skip to content
Permalink
Browse files

prepare DB queries

  • Loading branch information...
Spreeuw committed Feb 13, 2019
1 parent 983793f commit 26895352b73a77d1b00a2360b09d1bc424a370d9
Showing with 3 additions and 3 deletions.
  1. +1 −1 includes/class-wcpdf-main.php
  2. +2 −2 includes/documents/class-wcpdf-sequential-number-store.php
@@ -562,7 +562,7 @@ public function remove_order_personal_data( $order ) {
foreach ( $number_stores as $store_name ) {
$order_id = $order->get_id();
$table_name = apply_filters( "wpo_wcpdf_number_store_table_name", "{$wpdb->prefix}wcpdf_{$store_name}", $store_name, 'auto_increment' ); // i.e. wp_wcpdf_invoice_number
$wpdb->query( "UPDATE $table_name SET order_id = 0 WHERE order_id = $order_id" );
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET order_id = 0 WHERE order_id = %s", $order_id ) );
}
}
@@ -143,7 +143,7 @@ public function set_next( $number = 1 ) {
// if AUTO_INCREMENT is not 1, we need to make sure we have a 'highest value' in case of server restarts
// https://serverfault.com/questions/228690/mysql-auto-increment-fields-resets-by-itself
$highest_number = (int) $number - 1;
$wpdb->query("ALTER TABLE {$this->table_name} AUTO_INCREMENT={$highest_number};");
$wpdb->query( $wpdb->prepare( "ALTER TABLE {$this->table_name} AUTO_INCREMENT=%d;", $highest_number ) );
$data = array(
'order_id' => 0,
'date' => get_date_from_gmt( date( 'Y-m-d H:i:s' ) ),
@@ -157,7 +157,7 @@ public function set_next( $number = 1 ) {
$wpdb->insert( $this->table_name, $data );
} else {
// simple scenario, no need to insert any rows
$wpdb->query("ALTER TABLE {$this->table_name} AUTO_INCREMENT={$number};");
$wpdb->query( $wpdb->prepare( "ALTER TABLE {$this->table_name} AUTO_INCREMENT=%d;", $number ) );
}
}

0 comments on commit 2689535

Please sign in to comment.
You can’t perform that action at this time.