52         $aRawFields = 
oxDb::getDb()->MetaColumns($sTableName);
 
   53         if (is_array($aRawFields)) {
 
   54             foreach ($aRawFields as $oField) {
 
   55                 $aFields[$oField->name] = 
"{$sTableName}.{$oField->name}";
 
   72         $aTables = $oDb->getAll(
"show tables like " . $oDb->quote($sTableName));
 
   74         return count($aTables) > 0;
 
   87         $aTableFields = $this->
getFields($sTableName);
 
   88         $sTableName = strtoupper($sTableName);
 
   89         if (is_array($aTableFields)) {
 
   90             $sFieldName = strtoupper($sFieldName);
 
   91             $aTableFields = array_map(
'strtoupper', $aTableFields);
 
   92             if (in_array(
"{$sTableName}.{$sFieldName}", $aTableFields)) {
 
  109         if (empty($this->_aTables)) {
 
  113             foreach ($aTables as $aTableInfo) {
 
  114                 $sTableName = $aTableInfo[0];
 
  116                 $this->_aTables[] = $aTableInfo[0];
 
  132         $aMLTables = array();
 
  134             $sLangTableName = getLangTableName($sTable, $iLangId);
 
  135             if ($sTable != $sLangTableName && !in_array($sLangTableName, $aMLTables)) {
 
  136                 $aMLTables[] = $sLangTableName;
 
  154         $sTableSet = getLangTableName($sTable, $iLang);
 
  156         $aRes = 
oxDb::getDb()->getAll(
"show create table {$sTable}");
 
  157         $sSql = 
"CREATE TABLE `{$sTableSet}` (" .
 
  158                 "`OXID` char(32) COLLATE latin1_general_ci NOT NULL, " .
 
  159                 "PRIMARY KEY (`OXID`)" .
 
  160                 ") " . strstr($aRes[0][1], 
'ENGINE=');
 
  176     public function getAddFieldSql($sTable, $sField, $sNewField, $sPrevField, $sTableSet = null)
 
  179             $sTableSet = $sTable;
 
  181         $aRes = 
oxDb::getDb()->getAll(
"show create table {$sTable}");
 
  182         $sTableSql = $aRes[0][1];
 
  185         $sTableSql = preg_replace(
'/COMMENT \\\'.*?\\\'/', 
'', $sTableSql);
 
  186         preg_match(
"/.*,\s+(['`]?" . preg_quote($sField, 
'/') . 
"['`]?\s+[^,]+),.*/", $sTableSql, $aMatch);
 
  187         $sFieldSql = $aMatch[1];
 
  190         if (!empty($sFieldSql)) {
 
  191             $sFieldSql = preg_replace(
"/" . preg_quote($sField, 
'/') . 
"/", $sNewField, $sFieldSql);
 
  192             $sSql = 
"ALTER TABLE `$sTableSet` ADD " . $sFieldSql;
 
  194                 $sSql .= 
" AFTER `$sPrevField`";
 
  214         $aRes = 
oxDb::getDb()->getAll(
"show create table {$sTable}");
 
  216         $sTableSql = $aRes[0][1];
 
  218         preg_match_all(
"/([\w]+\s+)?\bKEY\s+(`[^`]+`)?\s*\([^)]+\)/iU", $sTableSql, $aMatch);
 
  219         $aIndex = $aMatch[0];
 
  221         $blUsingTableSet = $sTableSet ? 
true : 
false;
 
  224             $sTableSet = $sTable;
 
  227         $aIndexSql = array();
 
  229         if (count($aIndex)) {
 
  230             foreach ($aIndex as $sIndexSql) {
 
  231                 if (preg_match(
"/\([^)]*\b" . $sField . 
"\b[^)]*\)/i", $sIndexSql)) {
 
  234                     $sIndexSql = preg_replace(
"/(.*\bKEY\s+)`[^`]+`/", 
"$1", $sIndexSql);
 
  236                     if ($blUsingTableSet) {
 
  238                         $sIndexSql = preg_replace(
"/\([^\)]+\)/", 
"(`$sNewField`)", $sIndexSql);
 
  241                         $sIndexSql = preg_replace(
"/\b" . $sField . 
"\b/", $sNewField, $sIndexSql);
 
  244                     $aIndexSql[] = 
"ADD " . $sIndexSql;
 
  247             if (count($aIndexSql)) {
 
  248                 $aSql = array(
"ALTER TABLE `$sTableSet` " . implode(
", ", $aIndexSql));
 
  263         if (isset($this->_iCurrentMaxLangId)) {
 
  267         $sTable = $sTableSet = 
"oxarticles";
 
  268         $sField = $sFieldSet = 
"oxtitle";
 
  272             $sTableSet = getLangTableName($sTable, $iLang);
 
  273             $sFieldSet = $sField . 
'_' . $iLang;
 
  276         $this->_iCurrentMaxLangId = --$iLang;
 
  301         $aMultiLangFields = array();
 
  303         foreach ($aFields as $sField) {
 
  304             if (preg_match(
"/({$sTable}\.)?(?<field>.+)_1$/", $sField, $aMatches)) {
 
  305                 $aMultiLangFields[] = $aMatches[
'field'];
 
  309         return $aMultiLangFields;
 
  322         $sLangTable = getLangTableName($sTable, $iLang);
 
  324         $aBaseFields = $this->
getFields($sTable);
 
  325         $aLangFields = $this->
getFields($sLangTable);
 
  330         $aFields = array_merge($aBaseFields, $aLangFields);
 
  331         $aSingleLangFields = array();
 
  333         foreach ($aFields as $sFieldName => $sField) {
 
  334             if (preg_match(
"/(({$sTable}|{$sLangTable})\.)?(?<field>.+)_(?<lang>[0-9]+)$/", $sField, $aMatches)) {
 
  335                 if ($aMatches[
'lang'] == $iLang) {
 
  336                     $aSingleLangFields[$aMatches[
'field']] = $sField;
 
  339                 $aSingleLangFields[$sFieldName] = $sField;
 
  343         return $aSingleLangFields;
 
  369         $iLangId = (int) $iLangId;
 
  371         if ($iLangId === 0) {
 
  378         if (is_array($aFields) && count($aFields) > 0) {
 
  379             foreach ($aFields as $sFieldName) {
 
  380                 $sFieldName = $sFieldName . 
"_" . $iLangId;
 
  382                 if ($this->
fieldExists($sFieldName, $sTableName)) {
 
  384                     $aSql[] = 
"UPDATE {$sTableName} SET {$sFieldName} = DEFAULT;";
 
  401         $this->_iCurrentMaxLangId = null;
 
  405         foreach ($aTable as $sTableName) {
 
  423         if ((
int) $iLangId === 0) {
 
  430         foreach ($this->_aSkipTablesOnReset as $sSkipTable) {
 
  432             if (($iSkipId = array_search($sSkipTable, $aTables)) !== 
false) {
 
  433                 unset($aTables[$iSkipId]);
 
  437         foreach ($aTables as $sTableName) {
 
  451         if (is_array($aSql) && !empty($aSql)) {
 
  452             foreach ($aSql as $sSql) {
 
  455                     $oDb->execute($sSql);
 
  477         $aShops = $oDb->getAll(
"select * from oxshops");
 
  479         $aTables = $aTables ? $aTables : $oConfig->getConfigParam(
'aMultiShopTables');
 
  482         foreach ($aShops as $aShop) {
 
  483             $sShopId = $aShop[0];
 
  484             $oShop = 
oxNew(
'oxshop');
 
  485             $oShop->load($sShopId);
 
  486             $oShop->setMultiShopTables($aTables);
 
  487             $aMallInherit = array();
 
  488             foreach ($aTables as $sTable) {
 
  489                 $aMallInherit[$sTable] = $oConfig->getShopConfVar(
'blMallInherit_' . $sTable, $sShopId);
 
  491             if (!$oShop->generateViews(
false, $aMallInherit) && $bSuccess) {
 
  509         foreach ($this->aForceOriginalFields as $aFieldname) {
 
  510             if (array_key_exists($aFieldname, $aFields)) {
 
  511                 unset($aFields[$aFieldname]);
 
  526         $aMultiLanguageTables = $this->
getConfig()->getConfigParam(
'aMultiLangTables');
 
  528         if (!is_array($aMultiLanguageTables) || empty($aMultiLanguageTables)) {
 
  532         foreach ($aMultiLanguageTables as $sTable) {
 
  537                 for ($i=1;$i<=$iMaxLang;$i++) {
 
  556         $sTableSet = getLangTableName($sTable, $iLanguageId);
 
  561         if (is_array($aFields) && count($aFields) > 0) {
 
  562             foreach ($aFields as $sField) {
 
  563                 $sNewFieldName = $sField . 
"_" . $iLanguageId;
 
  564                 if ($iLanguageId > 1) {
 
  565                     $iPrevLang = $iLanguageId - 1;
 
  566                     $sPrevField = $sField . 
'_' . $iPrevLang;
 
  568                     $sPrevField = $sField;
 
  574                     $aSql[] = $this->
getAddFieldSql($sTable, $sField, $sNewFieldName, $sPrevField, $sTableSet);
 
  577                     $aSql = array_merge($aSql, (array) $this->
getAddFieldIndexSql($sTable, $sField, $sNewFieldName, $sTableSet));