src/SearchBundle/objects/db/TShopSearchIndexer.class.php
public function CreateIndexTables()
    {
        $aIndexTableNames = TdbShopSearchIndexer::GetAllIndexTableNames();
        $aTmpIndex = array();
        foreach ($aIndexTableNames as $sTableName => $length) {
            $aTmpIndex['_tmp'.$sTableName] = $length;
        }
        $aIndexTableNames = $aTmpIndex;
        foreach ($aIndexTableNames as $sTableName => $iLength) {
            if (TCMSRecord::TableExists($sTableName)) {
                $query = "DROP TABLE `{$sTableName}`";
                MySqlLegacySupport::getInstance()->query($query);
            }
            $sPrimaryKey = '';
            $query = 'CREATE TABLE `'.MySqlLegacySupport::getInstance()->real_escape_string($sTableName)."` (
                    `shop_article_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'the shop article',
                    `substring` CHAR( {$iLength} ) NOT NULL COMMENT 'the substring',
                    `cms_language_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'language of substring',
                    `occurrences` INT NOT NULL COMMENT 'Number of times the substring occured in the field for that article',
                    `weight` FLOAT NOT NULL COMMENT 'calculated weight for the substring',
                    `shop_search_field_weight_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'field for which the search term was made'
                    {$sPrimaryKey}
                  )";
            MySqlLegacySupport::getInstance()->query($query);
        }

        // drop index fields not needed
        $sBaseName = '_tmp'.self::INDEX_TBL_PREFIX;
        $query = "SHOW TABLES LIKE '".MySqlLegacySupport::getInstance()->real_escape_string($sBaseName)."%'";
        $rTableRes = MySqlLegacySupport::getInstance()->query($query);
        while ($aTableData = MySqlLegacySupport::getInstance()->fetch_row($rTableRes)) {
            if (!array_key_exists($aTableData[0], $aIndexTableNames)) {
                $query = 'DROP TABLE `'.MySqlLegacySupport::getInstance()->real_escape_string($aTableData[0]).'`';
                MySqlLegacySupport::getInstance()->query($query);
            }
        }
    }
public function CreateIndexTables()
    {
        $aIndexTableNames = TdbShopSearchIndexer::GetAllIndexTableNames();
        $aTmpIndex = array();
        foreach ($aIndexTableNames as $sTableName => $length) {
            $aTmpIndex['_tmp'.$sTableName] = $length;
        }
        $aIndexTableNames = $aTmpIndex;
        foreach ($aIndexTableNames as $sTableName => $iLength) {
            if (TCMSRecord::TableExists($sTableName)) {
                $query = "DROP TABLE `{$sTableName}`";
                MySqlLegacySupport::getInstance()->query($query);
            }
            $sPrimaryKey = '';
            $query = 'CREATE TABLE `'.MySqlLegacySupport::getInstance()->real_escape_string($sTableName)."` (
                    `shop_article_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'the shop article',
                    `substring` CHAR( {$iLength} ) NOT NULL COMMENT 'the substring',
                    `cms_language_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'language of substring',
                    `occurrences` INT NOT NULL COMMENT 'Number of times the substring occured in the field for that article',
                    `weight` FLOAT NOT NULL COMMENT 'calculated weight for the substring',
                    `shop_search_field_weight_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'field for which the search term was made'
                    {$sPrimaryKey}
                  )";
            MySqlLegacySupport::getInstance()->query($query);
        }

        // drop index fields not needed
        $sBaseName = '_tmp'.self::INDEX_TBL_PREFIX;
        $query = "SHOW TABLES LIKE '".MySqlLegacySupport::getInstance()->real_escape_string($sBaseName)."%'";
        $rTableRes = MySqlLegacySupport::getInstance()->query($query);
        while ($aTableData = MySqlLegacySupport::getInstance()->fetch_row($rTableRes)) {
            if (!array_key_exists($aTableData[0], $aIndexTableNames)) {
                $query = 'DROP TABLE `'.MySqlLegacySupport::getInstance()->real_escape_string($aTableData[0]).'`';
                MySqlLegacySupport::getInstance()->query($query);
            }
        }
    }
public function CreateIndexTables ( ) { $ aIndexTableNames = TdbShopSearchIndexer :: GetAllIndexTableNames ( ) ; $ aTmpIndex = array ( ) ; foreach ( $ aIndexTableNames as $ sTableName => $ length ) { $ aTmpIndex [ '_tmp' . $ sTableName ] = $ length ; } $ aIndexTableNames = $ aTmpIndex ; foreach ( $ aIndexTableNames as $ sTableName => $ iLength ) { if ( TCMSRecord :: TableExists ( $ sTableName ) ) { $ query = "DROP TABLE `{$sTableName}`" ; MySqlLegacySupport :: getInstance ( ) -> query ( $ query ) ; } $ sPrimaryKey = '' ; $ query = 'CREATE TABLE `' . MySqlLegacySupport :: getInstance ( ) -> real_escape_string ( $ sTableName ) . "` (
                    `shop_article_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'the shop article',
                    `substring` CHAR( {$iLength} ) NOT NULL COMMENT 'the substring',
                    `cms_language_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'language of substring',
                    `occurrences` INT NOT NULL COMMENT 'Number of times the substring occured in the field for that article',
                    `weight` FLOAT NOT NULL COMMENT 'calculated weight for the substring',
                    `shop_search_field_weight_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'field for which the search term was made'
                    {$sPrimaryKey}
                  )" ; MySqlLegacySupport :: getInstance ( ) -> query ( $ query ) ; } // drop index fields not needed $ sBaseName = '_tmp' . self :: INDEX_TBL_PREFIX ; $ query = "SHOW TABLES LIKE '" . MySqlLegacySupport :: getInstance ( ) -> real_escape_string ( $ sBaseName ) . "%'" ; $ rTableRes = MySqlLegacySupport :: getInstance ( ) -> query ( $ query ) ; while ( $ aTableData = MySqlLegacySupport :: getInstance ( ) -> fetch_row ( $ rTableRes ) ) { if ( ! array_key_exists ( $ aTableData [ 0 ] , $ aIndexTableNames ) ) { $ query = 'DROP TABLE `' . MySqlLegacySupport :: getInstance ( ) -> real_escape_string ( $ aTableData [ 0 ] ) . '`' ; MySqlLegacySupport :: getInstance ( ) -> query ( $ query ) ; } } }
create all index tables for the field and drop tables no longer needed.
create all index tables for the field and drop tables no longer needed .