00001 <?php
00002
00003
00004
00005 require_once getShopBasePath() . 'core/adodblite/adodb.inc.php';
00006
00010 class oxDb extends oxSuperCfg
00011 {
00016 const FETCH_MODE_NUM = ADODB_FETCH_NUM;
00017
00022 const FETCH_MODE_ASSOC = ADODB_FETCH_ASSOC;
00023
00029 protected static $_instance = null;
00030
00036 protected static $_oDB = null;
00037
00038
00044 protected static $_aTblDescCache = array();
00045
00051 public static function getInstance()
00052 {
00053
00054 if ( defined( 'OXID_PHP_UNIT' ) ) {
00055 self::$_instance = modInstances::getMod( __CLASS__ );
00056 }
00057
00058 if ( !self::$_instance instanceof oxDb ) {
00059
00060
00061 self::$_instance = oxNew( 'oxdb' );
00062
00063 if ( defined( 'OXID_PHP_UNIT' ) ) {
00064 modInstances::addMod( __CLASS__, self::$_instance);
00065 }
00066 }
00067 return self::$_instance;
00068 }
00069
00075 protected function _getModules()
00076 {
00077
00078 $myConfig = $this->getConfig();
00079 if ( ( $iDebug = $myConfig->getConfigParam( 'iDebug' ) ) ) {
00080 include_once getShopBasePath() . 'core/adodblite/adodb-exceptions.inc.php';
00081 }
00082
00083 $sModules = '';
00084 if ( $iDebug == 2 || $iDebug == 3 || $iDebug == 4 || $iDebug == 7 ) {
00085 $sModules = 'perfmon';
00086 }
00087
00088
00089 if ( $myConfig->isAdmin() && $myConfig->getConfigParam( 'blLogChangesInAdmin' ) ) {
00090 $sModules .= ( $sModules ? ':' : '' ) . 'oxadminlog';
00091 }
00092
00093 return $sModules;
00094 }
00095
00103 protected function _setUp( $oDb )
00104 {
00105 $myConfig = $this->getConfig();
00106 $iDebug = $myConfig->getConfigParam( 'iDebug' );
00107 if ( $iDebug == 2 || $iDebug == 3 || $iDebug == 4 || $iDebug == 7 ) {
00108 try {
00109 $oDb->execute( 'truncate table adodb_logsql' );
00110 } catch ( ADODB_Exception $e ) {
00111
00112 }
00113 if ( method_exists( $oDb, "logSQL" ) ) {
00114 $oDb->logSQL( true );
00115 }
00116 }
00117
00118 $oDb->cacheSecs = 60 * 10;
00119 $oDb->execute( 'SET @@session.sql_mode = ""' );
00120
00121 if ( $myConfig->isUtf() ) {
00122 $oDb->execute( 'SET NAMES "utf8"' );
00123 $oDb->execute( 'SET CHARACTER SET utf8' );
00124 $oDb->execute( 'SET CHARACTER_SET_CONNECTION = utf8' );
00125 $oDb->execute( 'SET CHARACTER_SET_DATABASE = utf8' );
00126 $oDb->execute( 'SET character_set_results = utf8' );
00127 $oDb->execute( 'SET character_set_server = utf8' );
00128 } elseif ( ( $sConn = $myConfig->getConfigParam('sDefaultDatabaseConnection') ) != '' ) {
00129 $oDb->execute( 'SET NAMES "' . $sConn . '"' );
00130 }
00131 }
00132
00142 protected function _sendMail( $sEmail, $sSubject, $sBody )
00143 {
00144 include_once getShopBasePath() . 'core/phpmailer/class.phpmailer.php';
00145 $oMailer = new phpmailer();
00146 $oMailer->isMail();
00147
00148 $oMailer->From = $sEmail;
00149 $oMailer->AddAddress( $sEmail );
00150 $oMailer->Subject = $sSubject;
00151 $oMailer->Body = $sBody;
00152 return $oMailer->send();
00153 }
00154
00162 protected function _notifyConnectionErrors( $oDb )
00163 {
00164 $myConfig = $this->getConfig();
00165
00166 if ( ( $sAdminEmail = $myConfig->getConfigParam( 'sAdminEmail' ) ) ) {
00167 $sFailedShop = isset( $_REQUEST['shp'] ) ? addslashes( $_REQUEST['shp'] ) : 'Base shop';
00168
00169 $sDate = date( 'l dS of F Y h:i:s A');
00170 $sScript = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING'];
00171 $sReferer = $_SERVER['HTTP_REFERER'];
00172
00173
00174 $sWarningSubject = 'Offline warning!';
00175 $sWarningBody = "
00176 Database error in OXID eShop:
00177 Date: {$sDate}
00178 Shop: {$sFailedShop}
00179
00180 mysql error: " . $oDb->errorMsg()."
00181 mysql error no: " . $oDb->errorNo()."
00182
00183 Script: {$sScript}
00184 Referer: {$sReferer}";
00185
00186 $this->_sendMail( $sAdminEmail, $sWarningSubject, $sWarningBody );
00187 }
00188
00189
00190 $oEx = new oxConnectionException();
00191 $oEx->setMessage( 'EXCEPTION_CONNECTION_NODB' );
00192 $oEx->setConnectionError( $myConfig->getConfigParam( 'dbUser' ) . 's' . getShopBasePath() . $oDb->errorMsg() );
00193 throw $oEx;
00194 }
00195
00204 protected function _onConnectionError( $oDb )
00205 {
00206 $sVerPrefix = '';
00207 $sVerPrefix = '_ce';
00208
00209 $sConfig = join( '', file( getShopBasePath().'config.inc.php' ) );
00210 if ( strpos( $sConfig, '<dbHost'.$sVerPrefix.'>' ) !== false &&
00211 strpos( $sConfig, '<dbName'.$sVerPrefix.'>' ) !== false ) {
00212
00213 oxUtils::getInstance()->redirect( "setup/index.php", true, 302 );
00214 } else {
00215
00216 $this->_notifyConnectionErrors( $oDb );
00217 }
00218 }
00219
00220
00228 protected function _getDbInstance( $iInstType = false )
00229 {
00230 $oConfig = $this->getConfig();
00231
00232 $sHost = $oConfig->getConfigParam( "dbHost" );
00233 $sUser = $oConfig->getConfigParam( "dbUser" );
00234 $sPwd = $oConfig->getConfigParam( "dbPwd" );
00235 $sName = $oConfig->getConfigParam( "dbName" );
00236 $sType = $oConfig->getConfigParam( "dbType" );
00237
00238 $oDb = ADONewConnection( $sType, $this->_getModules() );
00239
00240
00241 if ( !$oDb->connect( $sHost, $sUser, $sPwd, $sName ) ) {
00242 $this->_onConnectionError( $oDb );
00243 }
00244
00245 $this->_setUp( $oDb );
00246
00247 return $oDb;
00248 }
00249
00250
00260 public static function getDb( $iFetchMode = oxDb::FETCH_MODE_NUM )
00261 {
00262
00263 if ( $iFetchMode === true ) {
00264 $iFetchMode = oxDb::FETCH_MODE_ASSOC;
00265 } elseif ( $iFetchMode === false ) {
00266 $iFetchMode = oxDb::FETCH_MODE_NUM;
00267 }
00268
00269 if ( defined( 'OXID_PHP_UNIT' ) ) {
00270 if ( isset( modDB::$unitMOD ) && is_object( modDB::$unitMOD ) ) {
00271 return modDB::$unitMOD;
00272 }
00273 }
00274
00275 if ( self::$_oDB === null ) {
00276
00277 $oInst = self::getInstance();
00278 $myConfig = $oInst->getConfig();
00279
00280 global $ADODB_SESSION_TBL,
00281 $ADODB_SESSION_CONNECT,
00282 $ADODB_SESSION_DRIVER,
00283 $ADODB_SESSION_USER,
00284 $ADODB_SESSION_PWD,
00285 $ADODB_SESSION_DB,
00286 $ADODB_SESS_LIFE,
00287 $ADODB_SESS_DEBUG;
00288
00289
00290
00291
00292
00293
00294
00295 $ADODB_SESS_LIFE = 3000 * 60;
00296 $ADODB_SESSION_TBL = "oxsessions";
00297 $ADODB_SESSION_DRIVER = $myConfig->getConfigParam( 'dbType' );
00298 $ADODB_SESSION_USER = $myConfig->getConfigParam( 'dbUser' );
00299 $ADODB_SESSION_PWD = $myConfig->getConfigParam( 'dbPwd' );
00300 $ADODB_SESSION_DB = $myConfig->getConfigParam( 'dbName' );
00301 $ADODB_SESSION_CONNECT = $myConfig->getConfigParam( 'dbHost' );
00302 $ADODB_SESS_DEBUG = false;
00303
00304 $oDb = oxNew( 'oxLegacyDb' );
00305 $oDb->setConnection( $oInst->_getDbInstance() );
00306
00307 self::$_oDB = $oDb;
00308 }
00309
00310 self::$_oDB->setFetchMode( $iFetchMode );
00311
00312 return self::$_oDB;
00313 }
00314
00324 public function getMultiLangFieldName( $sField )
00325 {
00326 return $sField . oxLang::getInstance()->getLanguageTag();
00327 }
00328
00339 public function isQuoteNeeded( $sFieldtype)
00340 {
00341 $aTypesWoQuotes = array('int', 'decimal', 'float', 'tinyint', 'smallint', 'mediumint', 'bigint', 'double');
00342 return !in_array( $sFieldtype, $aTypesWoQuotes);
00343 }
00344
00352 public function quoteArray( $aStrArray )
00353 {
00354 $oDb = self::getDb();
00355
00356 foreach ( $aStrArray as $sKey => $sString ) {
00357 $aStrArray[$sKey] = $oDb->quote( $sString );
00358 }
00359 return $aStrArray;
00360 }
00361
00367 public function resetTblDescCache()
00368 {
00369 self::$_aTblDescCache = array();
00370 }
00371
00379 public function getTableDescription( $sTableName )
00380 {
00381
00382 if ( isset( self::$_aTblDescCache[$sTableName] ) ) {
00383 return self::$_aTblDescCache[$sTableName];
00384 }
00385
00386 $aFields = self::getDb()->MetaColumns( $sTableName );
00387
00388 self::$_aTblDescCache[$sTableName] = $aFields;
00389
00390 return $aFields;
00391 }
00392
00402 public function convertDBDateTime( $oObject, $blToTimeStamp = false, $blOnlyDate = false )
00403 {
00404 $sDate = $oObject->value;
00405
00406
00407 $sLocalDateFormat = $this->_defineAndCheckDefaultDateValues( $blToTimeStamp );
00408 $sLocalTimeFormat = $this->_defineAndCheckDefaultTimeValues( $blToTimeStamp );
00409
00410
00411 $aDefDatePatterns = $this->_defaultDatePattern();
00412
00413
00414 $aDatePatterns = $this->_regexp2ValidateDateInput();
00415 $aTimePatterns = $this->_regexp2ValidateTimeInput();
00416
00417
00418 $aDFormats = $this->_defineDateFormattingRules();
00419 $aTFormats = $this->_defineTimeFormattingRules();
00420
00421
00422 if ( !$sDate) {
00423 $this->_setDefaultDateTimeValue($oObject, $sLocalDateFormat, $sLocalTimeFormat, $blOnlyDate);
00424 return $oObject->value;
00425 }
00426
00427 $blDefDateFound = false;
00428 $oStr = getStr();
00429
00430
00431 foreach ( array_keys( $aDefDatePatterns ) as $sDefDatePattern ) {
00432 if ( $oStr->preg_match( $sDefDatePattern, $sDate)) {
00433 $blDefDateFound = true;
00434 break;
00435 }
00436 }
00437
00438
00439 if ( $blDefDateFound) {
00440 $this->_setDefaultFormatedValue($oObject, $sDate, $sLocalDateFormat, $sLocalTimeFormat, $blOnlyDate);
00441 return $oObject->value;
00442 }
00443
00444 $blDateFound = false;
00445 $blTimeFound = false;
00446 $aDateMatches = array();
00447 $aTimeMatches = array();
00448
00449
00450 foreach ( $aDatePatterns as $sPattern => $sType) {
00451 if ( $oStr->preg_match( $sPattern, $sDate, $aDateMatches)) {
00452 $blDateFound = true;
00453
00454
00455 $sDateFormat = $aDFormats[$sLocalDateFormat][0];
00456 $aDFields = $aDFormats[$sType][1];
00457 break;
00458 }
00459 }
00460
00461
00462 if ( !$blDateFound) {
00463 return $sDate;
00464 }
00465
00466 if ( $blOnlyDate) {
00467 $this->_setDate($oObject, $sDateFormat, $aDFields, $aDateMatches);
00468 return $oObject->value;
00469 }
00470
00471
00472 foreach ( $aTimePatterns as $sPattern => $sType) {
00473 if ( $oStr->preg_match( $sPattern, $sDate, $aTimeMatches)) {
00474 $blTimeFound = true;
00475
00476
00477 $sTimeFormat = $aTFormats[$sLocalTimeFormat][0];
00478 $aTFields = $aTFormats[$sType][1];
00479
00480
00481 if ( $sType == "USA" && isset($aTimeMatches[4])) {
00482 $iIntVal = (int) $aTimeMatches[1];
00483 if ( $aTimeMatches[4] == "PM") {
00484 if ( $iIntVal < 13) {
00485 $iIntVal += 12;
00486 }
00487 } elseif ( $aTimeMatches[4] == "AM" && $aTimeMatches[1] == "12") {
00488 $iIntVal = 0;
00489 }
00490
00491 $aTimeMatches[1] = sprintf("%02d", $iIntVal);
00492 }
00493
00494 break;
00495 }
00496 }
00497
00498 if ( !$blTimeFound) {
00499
00500
00501 $this->_setDate($oObject, $sDateFormat, $aDFields, $aDateMatches);
00502 return $oObject->value;
00503 }
00504
00505 $this->_formatCorrectTimeValue($oObject, $sDateFormat, $sTimeFormat, $aDateMatches, $aTimeMatches, $aTFields, $aDFields);
00506
00507
00508 if ( !$oObject->fldmax_length) {
00509 return $this->convertDBDateTime( $oObject, $blToTimeStamp, $blOnlyDate);
00510 }
00511 return $oObject->value;
00512 }
00513
00522 public function convertDBTimestamp( $oObject, $blToTimeStamp = false )
00523 {
00524
00525 $sSQLTimeStampPattern = "/^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$/";
00526 $sISOTimeStampPattern = "/^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/";
00527 $aMatches = array();
00528 $oStr = getStr();
00529
00530
00531 if ( $blToTimeStamp) {
00532
00533 $this->convertDBDateTime( $oObject, $blToTimeStamp );
00534
00535 if ( $oStr->preg_match( $sISOTimeStampPattern, $oObject->value, $aMatches)) {
00536
00537 $oObject->setValue($aMatches[1].$aMatches[2].$aMatches[3].$aMatches[4].$aMatches[5].$aMatches[6]);
00538 $oObject->fldmax_length = strlen( $oObject->value);
00539 return $oObject->value;
00540 }
00541 } else {
00542
00543
00544
00545 if ( $oStr->preg_match( $sSQLTimeStampPattern, $oObject->value, $aMatches ) ) {
00546 $iTimestamp = mktime( $aMatches[4],
00547 $aMatches[5],
00548 $aMatches[6],
00549 $aMatches[2],
00550 $aMatches[3],
00551 $aMatches[1]);
00552 if ( !$iTimestamp ) {
00553 $iTimestamp = "0";
00554 }
00555
00556 $oObject->setValue(trim( date( "Y-m-d H:i:s", $iTimestamp)));
00557 $oObject->fldmax_length = strlen( $oObject->value);
00558 $this->convertDBDateTime( $oObject, $blToTimeStamp );
00559 return $oObject->value;
00560 }
00561 }
00562 }
00563
00572 public function convertDBDate( $oObject, $blToTimeStamp = false )
00573 {
00574 return $this->convertDBDateTime( $oObject, $blToTimeStamp, true );
00575 }
00576
00586 public function createSQLList( $aArray )
00587 {
00588 $sRet = "";
00589
00590 $blSep = false;
00591 foreach ( $aArray as $aToken) {
00592 if ( !$aToken[0]) {
00593 continue;
00594 }
00595 if ( $blSep) {
00596 $sRet .= ",";
00597 }
00598 $sRet .= "'".$aToken[0]."'";
00599 $blSep = true;
00600 }
00601 return $sRet;
00602 }
00603
00611 static public function startTransaction()
00612 {
00613 return self::getDb()->execute( 'START TRANSACTION' );
00614 }
00615
00623 static public function commitTransaction()
00624 {
00625 return self::getDb()->execute( 'COMMIT' );
00626 }
00627
00635 static public function rollbackTransaction()
00636 {
00637 return self::getDb()->execute( 'ROLLBACK' );
00638 }
00639
00650 static public function setTransactionIsolationLevel( $sLevel = null )
00651 {
00652 $aLevels = array( 'READ UNCOMMITTED', 'READ COMMITTED', 'REPEATABLE READ', 'SERIALIZABLE' );
00653 if ( in_array( strtoupper( $sLevel ), $aLevels ) ) {
00654 return self::getDb()->execute( 'SET TRANSACTION ISOLATION LEVEL ' . $sLevel );
00655 }
00656 }
00657
00658
00667 public function isValidFieldName( $sField )
00668 {
00669 return ( boolean ) getStr()->preg_match( "#^[\w\d\._]*$#", $sField );
00670 }
00671
00683 protected function _setDefaultFormatedValue( $oObject, $sDate, $sLocalDateFormat, $sLocalTimeFormat, $blOnlyDate )
00684 {
00685 $aDefTimePatterns = $this->_defaultTimePattern();
00686 $aDFormats = $this->_defineDateFormattingRules();
00687 $aTFormats = $this->_defineTimeFormattingRules();
00688 $oStr = getStr();
00689
00690 foreach ( array_keys( $aDefTimePatterns ) as $sDefTimePattern ) {
00691 if ( $oStr->preg_match( $sDefTimePattern, $sDate ) ) {
00692 $blDefTimeFound = true;
00693 break;
00694 }
00695 }
00696
00697
00698 if ( $blOnlyDate) {
00699 $oObject->setValue(trim( $aDFormats[$sLocalDateFormat][2] ));
00700
00701 $oObject->fldmax_length = strlen( $oObject->value );
00702 return ;
00703 } elseif ( $blDefTimeFound ) {
00704
00705 $oObject->setValue(trim( $aDFormats[$sLocalDateFormat][2] . " " . $aTFormats[$sLocalTimeFormat][2] ));
00706
00707 $oObject->fldmax_length = strlen( $oObject->value );
00708 return ;
00709 }
00710 }
00711
00719 protected function _defineAndCheckDefaultTimeValues( $blToTimeStamp )
00720 {
00721
00722
00723 $sLocalTimeFormat = $this->getConfig()->getConfigParam( 'sLocalTimeFormat' );
00724 if ( !$sLocalTimeFormat || $blToTimeStamp) {
00725 $sLocalTimeFormat = "ISO";
00726 }
00727 return $sLocalTimeFormat;
00728 }
00729
00737 protected function _defineAndCheckDefaultDateValues( $blToTimeStamp )
00738 {
00739
00740
00741 $sLocalDateFormat = $this->getConfig()->getConfigParam( 'sLocalDateFormat' );
00742 if ( !$sLocalDateFormat || $blToTimeStamp) {
00743 $sLocalDateFormat = "ISO";
00744 }
00745 return $sLocalDateFormat;
00746 }
00747
00753 protected function _defaultDatePattern()
00754 {
00755
00756 $aDefDatePatterns = array("/^0000-00-00/" => "ISO",
00757 "/^00\.00\.0000/" => "EUR",
00758 "/^00\/00\/0000/" => "USA"
00759 );
00760 return $aDefDatePatterns;
00761 }
00762
00768 protected function _defaultTimePattern()
00769 {
00770
00771 $aDefTimePatterns = array("/00:00:00$/" => "ISO",
00772 "/00\.00\.00$/" => "EUR",
00773 "/00:00:00 AM$/" => "USA"
00774 );
00775 return $aDefTimePatterns;
00776 }
00777
00783 protected function _regexp2ValidateDateInput()
00784 {
00785
00786 $aDatePatterns = array("/^([0-9]{4})-([0-9]{2})-([0-9]{2})/" => "ISO",
00787 "/^([0-9]{2})\.([0-9]{2})\.([0-9]{4})/" => "EUR",
00788 "/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})/" => "USA"
00789 );
00790 return $aDatePatterns;
00791 }
00792
00798 protected function _regexp2ValidateTimeInput()
00799 {
00800
00801 $aTimePatterns = array("/([0-9]{2}):([0-9]{2}):([0-9]{2})$/" => "ISO",
00802 "/([0-9]{2})\.([0-9]{2})\.([0-9]{2})$/" => "EUR",
00803 "/([0-9]{2}):([0-9]{2}):([0-9]{2}) ([AP]{1}[M]{1})$/" => "USA"
00804 );
00805 return $aTimePatterns;
00806 }
00807
00813 protected function _defineDateFormattingRules()
00814 {
00815
00816 $aDFormats = array("ISO" => array("Y-m-d", array(2, 3, 1), "0000-00-00"),
00817 "EUR" => array("d.m.Y", array(2, 1, 3), "00.00.0000"),
00818 "USA" => array("m/d/Y", array(1, 2, 3), "00/00/0000")
00819 );
00820 return $aDFormats;
00821 }
00822
00828 protected function _defineTimeFormattingRules()
00829 {
00830
00831 $aTFormats = array("ISO" => array("H:i:s", array(1, 2, 3 ), "00:00:00"),
00832 "EUR" => array("H.i.s", array(1, 2, 3 ), "00.00.00"),
00833 "USA" => array("h:i:s A", array(1, 2, 3 ), "00:00:00 AM")
00834 );
00835 return $aTFormats;
00836 }
00837
00848 protected function _setDefaultDateTimeValue( $oObject, $sLocalDateFormat, $sLocalTimeFormat, $blOnlyDate )
00849 {
00850 $aDFormats = $this->_defineDateFormattingRules();
00851 $aTFormats = $this->_defineTimeFormattingRules();
00852
00853 $sReturn = $aDFormats[$sLocalDateFormat][2];
00854 if ( !$blOnlyDate) {
00855 $sReturn .= " ".$aTFormats[$sLocalTimeFormat][2];
00856 }
00857
00858 if ($oObject instanceof oxField) {
00859 $oObject->setValue(trim($sReturn));
00860 } else {
00861 $oObject->value = trim($sReturn);
00862 }
00863
00864 $oObject->fldmax_length = strlen( $oObject->value);
00865 }
00866
00877 protected function _setDate( $oObject, $sDateFormat, $aDFields, $aDateMatches )
00878 {
00879
00880 $iTimestamp = mktime( 0, 0, 0, $aDateMatches[$aDFields[0]],
00881 $aDateMatches[$aDFields[1]],
00882 $aDateMatches[$aDFields[2]]);
00883
00884 if ($oObject instanceof oxField) {
00885 $oObject->setValue(@date( $sDateFormat, $iTimestamp ));
00886 } else {
00887 $oObject->value = @date( $sDateFormat, $iTimestamp );
00888 }
00889
00890 $oObject->fldmax_length = strlen( $oObject->value );
00891 }
00892
00906 protected function _formatCorrectTimeValue( $oObject, $sDateFormat, $sTimeFormat, $aDateMatches, $aTimeMatches, $aTFields, $aDFields )
00907 {
00908
00909 $iTimestamp = @mktime( (int) $aTimeMatches[$aTFields[0]],
00910 (int) $aTimeMatches[$aTFields[1]],
00911 (int) $aTimeMatches[$aTFields[2]],
00912 (int) $aDateMatches[$aDFields[0]],
00913 (int) $aDateMatches[$aDFields[1]],
00914 (int) $aDateMatches[$aDFields[2]] );
00915
00916 if ($oObject instanceof oxField) {
00917 $oObject->setValue(trim( @date( $sDateFormat." ".$sTimeFormat, $iTimestamp ) ));
00918 } else {
00919 $oObject->value = trim( @date( $sDateFormat." ".$sTimeFormat, $iTimestamp ) );
00920 }
00921
00922
00923 $oObject->fldmax_length = strlen( $oObject->value );
00924 }
00925
00931 protected function _getConnectionId()
00932 {
00933 return self::getDb()->getDb()->connectionId;
00934 }
00935
00943 public function escapeString( $sString )
00944 {
00945 $myConfig = $this->getConfig();
00946 if ( 'mysql' == $myConfig->getConfigParam( "dbType" )) {
00947 return mysql_real_escape_string( $sString, $this->_getConnectionId() );
00948 } elseif ( 'mysqli' == $myConfig->getConfigParam( "dbType" )) {
00949 return mysqli_real_escape_string( $this->_getConnectionId(), $sString );
00950 } else {
00951 return mysql_real_escape_string( $sString, $this->_getConnectionId() );
00952 }
00953 }
00954
00962 public function updateViews( $aTables = null )
00963 {
00964 set_time_limit(0);
00965
00966 $myConfig = $this->getConfig();
00967 $oShopList = oxNew("oxshoplist" );
00968 $oShopList->selectString( "select * from oxshops");
00969
00970 $aTables = $aTables ? $aTables : $myConfig->getConfigParam( 'aMultiShopTables' );
00971 foreach ( $oShopList as $key => $oShop ) {
00972 $oShop->setMultiShopTables( $aTables );
00973 $blMultishopInherit = $myConfig->getShopConfVar( 'blMultishopInherit_oxcategories', $oShop->sOXID );
00974 $aMallInherit = array();
00975 foreach ( $aTables as $sTable ) {
00976 $aMallInherit[$sTable] = $myConfig->getShopConfVar( 'blMallInherit_' . $sTable, $oShop->sOXID );
00977 }
00978 $oShop->generateViews( $blMultishopInherit, $aMallInherit );
00979 }
00980 }
00981 }