L
L
LoveCode &Coffe2018-09-04 02:20:37
opencart
LoveCode &Coffe, 2018-09-04 02:20:37

Opencart 2.3.0.2 import/export not working. How to fix?

Import / export from the admin panel does not work. Spreads the same error all over the screen

Notice: Undefined index: Tables_in_Market_giersch in D:\OSPanel\domains\Market.loc\admin\model\tool\backup.php on line 21Notice: Undefined index: Tables_in_Market_giersch in

I read somewhere that such a problem may be due to the fact that the database is capitalized. At me once it is registered with the big. If this is the reason. Can I somehow modify the backup.php file. And remove this error?
Here is the whole file
<?php
class ModelToolBackup extends Model {
  public function restore($sql) {
    foreach (explode(";\n", $sql) as $sql) {
      $sql = trim($sql);

      if ($sql) {
        $this->db->query($sql);
      }
    }

    $this->cache->delete('*');
  }

  public function getTables() {
    $table_data = array();

    $query = $this->db->query("SHOW TABLES FROM `" . DB_DATABASE . "`");

    foreach ($query->rows as $result) {
      if (utf8_substr($result['Tables_in_' . DB_DATABASE], 0, strlen(DB_PREFIX)) == DB_PREFIX) {
        if (isset($result['Tables_in_' . DB_DATABASE])) {
          $table_data[] = $result['Tables_in_' . DB_DATABASE];
        }
      }
    }

    return $table_data;
  }

  public function backup($tables) {
    $output = '';

    foreach ($tables as $table) {
      if (DB_PREFIX) {
        if (strpos($table, DB_PREFIX) === false) {
          $status = false;
        } else {
          $status = true;
        }
      } else {
        $status = true;
      }

      if ($status) {
        $output .= 'TRUNCATE TABLE `' . $table . '`;' . "\n\n";

        $query = $this->db->query("SELECT * FROM `" . $table . "`");

        foreach ($query->rows as $result) {
          $fields = '';

          foreach (array_keys($result) as $value) {
            $fields .= '`' . $value . '`, ';
          }

          $values = '';

          foreach (array_values($result) as $value) {
            $value = str_replace(array("\x00", "\x0a", "\x0d", "\x1a"), array('\0', '\n', '\r', '\Z'), $value);
            $value = str_replace(array("\n", "\r", "\t"), array('\n', '\r', '\t'), $value);
            $value = str_replace('\\', '\\\\',	$value);
            $value = str_replace('\'', '\\\'',	$value);
            $value = str_replace('\\\n', '\n',	$value);
            $value = str_replace('\\\r', '\r',	$value);
            $value = str_replace('\\\t', '\t',	$value);

            $values .= '\'' . $value . '\', ';
          }

          $output .= 'INSERT INTO `' . $table . '` (' . preg_replace('/, $/', '', $fields) . ') VALUES (' . preg_replace('/, $/', '', $values) . ');' . "\n";
        }

        $output .= "\n\n";
      }
    }

    return $output;
  }
}

and here is the line from this file to which the error refers
if (utf8_substr($result['Tables_in_' . DB_DATABASE], 0, strlen(DB_PREFIX)) == DB_PREFIX) {

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question