# table installation


            $version = get_option($this->tableImpressions);
            if ($version != $this->tableImpressions_version) {
                if ($this->db->get_var('SHOW TABLES LIKE "'. $this->tableImpressions .'_backup"') == $this->tableImpressions .'_backup') {
                    $q = 'CREATE TABLE `'. $this->tableImpressions .'_backup_2` LIKE `'. $this->tableImpressions .'_backup`';
                    $this->db->query($q);

                    $q2 = 'INSERT INTO `'. $this->tableImpressions .'_backup_2` SELECT * FROM `'. $this->tableImpressions .'_backup`';
                    $this->db->query($q2);

                    $q3 = 'DROP TABLE `'. $this->tableImpressions .'_backup`';
                    $this->db->query($q3);
                }


                if ($this->tableImpressions_version == '1.0.0') {
                    $table = 'CREATE TABLE `'. $this->tableImpressions .'` (
                        `id`            INT(10)         NOT NULL AUTO_INCREMENT PRIMARY KEY,
                        `name`          VARCHAR(64)     NOT NULL,

                        `homepage`      INT(5)          NOT NULL DEFAULT 0,
                        `pages`         INT(5)          NOT NULL DEFAULT 0,
                        `pagesid`       VARCHAR(255)    NULL,
                        `posts`         INT(5)          NOT NULL DEFAULT 0,
                        `postsid`       VARCHAR(255)    NULL,

                        `created`       DATETIME        DEFAULT "0000-00-00 00:00:00",
						`modified`      DATETIME        DEFAULT "0000-00-00 00:00:00",
						`ip`            VARCHAR(255)    NOT NULL DEFAULT "127.0.0.1",
						`status`        INT(5)          NOT NULL DEFAULT 1
                    ) '. $this->tableCollation;
                }
                $this->execTable($table);


                if ($this->db->get_var('SHOW TABLES LIKE "'. $this->tableImpressions .'_backup_2"') == $this->tableImpressions .'_backup_2') {
                    $q = 'SELECT * FROM `'. $this->tableImpressions .'_backup_2`';
                    $res = $this->db->get_results($q, ARRAY_A);
                    if (0 != count($res)) {
                        foreach ($res as $data) {
                            if ($version == '1.0.0') {
                                $q2 = 'INSERT INTO `'. $this->tableImpressions .'` (
                                    `created`, `modified`, `ip`, `status`
                                ) VALUES (
                                    "'. $data['created'] .'", "'. $data['modified'] .'", "'. $data['ip'] .'", "'. $data['status'] .'"
                                )';
                            }
                            $this->db->query($q2);
                        }
                    }

                    $q3 = 'DROP TABLE `'. $this->tableImpressions .'_backup_2`';
                    $this->db->query($q3);
                }
            }
            else {
                if ($this->db->get_var('SHOW TABLES LIKE "'. $this->tableImpressions .'_backup"') == $this->tableImpressions .'_backup') {
                    $q = 'CREATE TABLE `'. $this->tableImpressions .'` LIKE `'. $this->tableImpressions .'_backup`';
                    $this->db->query($q);

                    $q2 = 'INSERT INTO `'. $this->tableImpressions .'` SELECT * FROM `'. $this->tableImpressions .'_backup`';
                    $this->db->query($q2);

                    $q3 = 'DROP TABLE `'. $this->tableImpressions .'_backup`';
                    $this->db->query($q3);
                }
            }
            update_option($this->tableImpressions, $this->tableImpressions_version);


# end of table installation



# table backup


            if ($this->db->get_var('SHOW TABLES LIKE "'. $this->tableImpressions .'_backup"') != $this->tableImpressions .'_backup') {
                $q = 'CREATE TABLE `'. $this->tableImpressions .'_backup` LIKE `'. $this->tableImpressions .'`';
                $this->db->query($q);

                $q2 = 'INSERT INTO `'. $this->tableImpressions .'_backup` SELECT * FROM `'. $this->tableImpressions .'`';
                $this->db->query($q2);

                $q3 = 'DROP TABLE `'. $this->tableImpressions .'`';
                $this->db->query($q3);
            }

# end of table backup