protected function dumpTables()
    {
        $this->tables->execute();

        foreach ($this->tables->fetchAll(\PDO::FETCH_ASSOC) as $a) {
            $table = current($a);

            if (isset($a['Table_type']) && $a['Table_type'] === 'VIEW') {
                continue;
            }

            if (in_array($table, (array) $this->config->ignore, true)) {
                continue;
            }

            if ((string) $this->config->prefix !== '' && strpos($table, $this->config->prefix) !== 0) {
                continue;
            }

            if ($this->config->structure === true) {
                $structure = $this->pdo->query('SHOW CREATE TABLE `'.$table.'`')->fetch(\PDO::FETCH_ASSOC);

                $this->write("\n-- Table structure for table `{$table}`\n", false);
                $this->write('DROP TABLE IF EXISTS `'.$table.'`');
                $this->write(end($structure));
            }

            if ($this->config->data === true) {
                $this->write("\n-- Dumping data for table `{$table}`\n", false);
                $this->write("LOCK TABLES `{$table}` WRITE");

                if (isset($this->config->select[$table])) {
                    $query = $this->config->select[$table];
                } else {
                    $query = 'SELECT * FROM `'.$table.'`';
                }

                $rows = $this->pdo->prepare($query);
                $rows->execute();

                while ($a = $rows->fetch(\PDO::FETCH_ASSOC)) {
                    $this->write(
                        "INSERT INTO `{$table}` VALUES (".
                        implode(',', array_map(array($this, 'escape'), $a)).
                        ")"
                    );
                }

                $this->write('UNLOCK TABLES');
            }
        }
    }