Skip to content

Commit

Permalink
prepare DB queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Spreeuw committed Feb 13, 2019
1 parent 983793f commit 2689535
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion includes/class-wcpdf-main.php
Expand Up @@ -562,7 +562,7 @@ public function remove_order_personal_data( $order ) {
foreach ( $number_stores as $store_name ) { foreach ( $number_stores as $store_name ) {
$order_id = $order->get_id(); $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 $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 ) );
} }
} }


Expand Down
4 changes: 2 additions & 2 deletions includes/documents/class-wcpdf-sequential-number-store.php
Expand Up @@ -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 // 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 // https://serverfault.com/questions/228690/mysql-auto-increment-fields-resets-by-itself
$highest_number = (int) $number - 1; $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( $data = array(
'order_id' => 0, 'order_id' => 0,
'date' => get_date_from_gmt( date( 'Y-m-d H:i:s' ) ), 'date' => get_date_from_gmt( date( 'Y-m-d H:i:s' ) ),
Expand All @@ -157,7 +157,7 @@ public function set_next( $number = 1 ) {
$wpdb->insert( $this->table_name, $data ); $wpdb->insert( $this->table_name, $data );
} else { } else {
// simple scenario, no need to insert any rows // 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 ) );
} }
} }


Expand Down

0 comments on commit 2689535

Please sign in to comment.