Plugin Directory

Changeset 3124590


Ignore:
Timestamp:
07/24/2024 12:07:52 PM (20 months ago)
Author:
databasebackup
Message:

cron-create-full-backup.php improvement

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-database-backup/tags/6.12/includes/admin/cron-create-full-backup.php

    r3124584 r3124590  
    395395                $output = '';
    396396                $sub_limit = 500;
    397                 //phpcs:ignore  -- Use PHP methods for large files
    398                 $check_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM %s", $table));
     397                //phpcs:ignore  -- need to get all tables
     398                $check_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `{$table}`"));
    399399                $check_count = intval($check_count);
    400400   
     
    404404                        $sub_offset = $sub_i * $sub_limit;
    405405                        // phpcs:ignore  -- need to get chunk of data for selected table
    406                         $sub_result = $wpdb->get_results($wpdb->prepare("SELECT * FROM %s LIMIT %d OFFSET %d", $table, $sub_limit, $sub_offset), ARRAY_A);
     406                        $sub_result = $wpdb->get_results($wpdb->prepare("SELECT * FROM `{$table}` LIMIT %d OFFSET %d", $sub_limit, $sub_offset), ARRAY_A);
    407407                        if ($sub_result) {
    408408                            $output .= wpdbbkp_create_sql_insert_statements($table, $sub_result);
     
    412412                } else {
    413413                    // phpcs:ignore  -- need to get all data for selected table
    414                     $result = $wpdb->get_results($wpdb->prepare("SELECT * FROM %s", $table), ARRAY_A);
     414                    $result = $wpdb->get_results($wpdb->prepare("SELECT * FROM `{$table}`"), ARRAY_A);
    415415                    $output .= wpdbbkp_create_sql_insert_statements($table, $result);
    416416                }
     
    418418
    419419                // phpcs:ignore  -- Get table structure for backup
    420                 $row2 = $wpdb->get_row($wpdb->prepare("SHOW CREATE TABLE %s", $table), ARRAY_N);
     420                $row2 = $wpdb->get_row($wpdb->prepare("SHOW CREATE TABLE `{$table}`"), ARRAY_N);
    421421                $output = "\n\n" . $row2[1] . ";\n\n" . $output;
    422422   
     
    452452                }
    453453   
    454                 $logMessage .= "\nBackup completed for table: $table";
     454                $logMessage .= "\nBackup completed for table: {$table}";
    455455            }
    456456   
Note: See TracChangeset for help on using the changeset viewer.