00001 <?php
00002
00003
00004
00005 require_once getShopBasePath() . 'core/adodblite/adodb.inc.php';
00006
00010 class oxDb
00011 {
00016 const FETCH_MODE_NUM = ADODB_FETCH_NUM;
00017
00022 const FETCH_MODE_ASSOC = ADODB_FETCH_ASSOC;
00023
00028 public static $configSet = false;
00029
00035 protected static $_instance = null;
00036
00042 protected static $_oDB = null;
00043
00049 protected static $_aTblDescCache = array();
00050
00055 private static $_dbType = '';
00056
00061 private static $_dbUser = '';
00062
00067 private static $_dbPwd = '';
00068
00073 private static $_dbName = '';
00074
00079 private static $_dbHost = '';
00080
00085 private static $_iDebug = 0;
00086
00091 private static $_blLogChangesInAdmin = false;
00092
00097 private static $_iUtfMode = 0;
00098
00103 private static $_sDefaultDatabaseConnection = null;
00104
00109 private static $_aSlaveHosts;
00110
00115 private static $_sAdminEmail;
00116
00121 private static $_iMasterSlaveBalance;
00122
00127 private static $_sLocalTimeFormat;
00128
00133 private static $_sLocalDateFormat;
00134
00142 public static function setConfig( $oConfig )
00143 {
00144 self::$_dbType = $oConfig->getVar( 'dbType' );
00145 self::$_dbUser = $oConfig->getVar( 'dbUser' );
00146 self::$_dbPwd = $oConfig->getVar( 'dbPwd' );
00147 self::$_dbName = $oConfig->getVar( 'dbName' );
00148 self::$_dbHost = $oConfig->getVar( 'dbHost' );
00149 self::$_iDebug = $oConfig->getVar( 'iDebug' );
00150 self::$_blLogChangesInAdmin = $oConfig->getVar( 'blLogChangesInAdmin' );
00151 self::$_iUtfMode = $oConfig->getVar( 'iUtfMode' );
00152 self::$_sDefaultDatabaseConnection = $oConfig->getVar( 'sDefaultDatabaseConnection' );
00153 self::$_aSlaveHosts = $oConfig->getVar( 'aSlaveHosts' );
00154 self::$_iMasterSlaveBalance = $oConfig->getVar( 'iMasterSlaveBalance' );
00155 self::$_sAdminEmail = $oConfig->getVar( 'sAdminEmail' );
00156 self::$_sLocalTimeFormat = $oConfig->getVar( 'sLocalTimeFormat' );
00157 self::$_sLocalDateFormat = $oConfig->getVar( 'sLocalDateFormat' );
00158 }
00159
00167 protected static function _getConfigParam( $sConfigName )
00168 {
00169 if ( isset( self::$$sConfigName ) ) {
00170 return self::$$sConfigName;
00171 }
00172
00173 return null;
00174 }
00175
00181 public static function getInstance()
00182 {
00183
00184 if ( defined( 'OXID_PHP_UNIT' ) ) {
00185 self::$_instance = modInstances::getMod( __CLASS__ );
00186 }
00187
00188 if ( !self::$_instance instanceof oxDb ) {
00189
00190
00191
00192 self::$_instance = new oxDb();
00193
00194 if ( defined( 'OXID_PHP_UNIT' ) ) {
00195 modInstances::addMod( __CLASS__, self::$_instance);
00196 }
00197 }
00198 return self::$_instance;
00199 }
00200
00206 protected function isAdmin()
00207 {
00208 return isAdmin();
00209 }
00210
00216 protected function _getModules()
00217 {
00218
00219 if ( ( $_iDebug = self::_getConfigParam( '_iDebug' ) ) ) {
00220 include_once getShopBasePath() . 'core/adodblite/adodb-exceptions.inc.php';
00221 }
00222
00223 $sModules = '';
00224 if ( $_iDebug == 2 || $_iDebug == 3 || $_iDebug == 4 || $_iDebug == 7 ) {
00225 $sModules = 'perfmon';
00226 }
00227
00228
00229 if ( $this->isAdmin() && self::_getConfigParam( '_blLogChangesInAdmin' ) ) {
00230 $sModules .= ( $sModules ? ':' : '' ) . 'oxadminlog';
00231 }
00232
00233 return $sModules;
00234 }
00235
00243 protected function _setUp( $oDb )
00244 {
00245 $_iDebug = self::_getConfigParam( '_iDebug' );
00246 if ( $_iDebug == 2 || $_iDebug == 3 || $_iDebug == 4 || $_iDebug == 7 ) {
00247 try {
00248 $oDb->execute( 'truncate table adodb_logsql' );
00249 } catch ( ADODB_Exception $e ) {
00250
00251 }
00252 if ( method_exists( $oDb, "logSQL" ) ) {
00253 $oDb->logSQL( true );
00254 }
00255 }
00256
00257 $oDb->cacheSecs = 60 * 10;
00258 $oDb->execute( 'SET @@session.sql_mode = ""' );
00259
00260 if ( self::_getConfigParam( '_iUtfMode' ) ) {
00261 $oDb->execute( 'SET NAMES "utf8"' );
00262 $oDb->execute( 'SET CHARACTER SET utf8' );
00263 $oDb->execute( 'SET CHARACTER_SET_CONNECTION = utf8' );
00264 $oDb->execute( 'SET CHARACTER_SET_DATABASE = utf8' );
00265 $oDb->execute( 'SET character_set_results = utf8' );
00266 $oDb->execute( 'SET character_set_server = utf8' );
00267 } elseif ( ( $sConn = self::_getConfigParam('_sDefaultDatabaseConnection') ) != '' ) {
00268 $oDb->execute( 'SET NAMES "' . $sConn . '"' );
00269 }
00270 }
00271
00281 protected function _sendMail( $sEmail, $sSubject, $sBody )
00282 {
00283 include_once getShopBasePath() . 'core/phpmailer/class.phpmailer.php';
00284 $oMailer = new phpmailer();
00285 $oMailer->isMail();
00286
00287 $oMailer->From = $sEmail;
00288 $oMailer->AddAddress( $sEmail );
00289 $oMailer->Subject = $sSubject;
00290 $oMailer->Body = $sBody;
00291 return $oMailer->send();
00292 }
00293
00301 protected function _notifyConnectionErrors( $oDb )
00302 {
00303
00304 if ( ( $sAdminEmail = self::_getConfigParam( '_sAdminEmail' ) ) ) {
00305 $sFailedShop = isset( $_REQUEST['shp'] ) ? addslashes( $_REQUEST['shp'] ) : 'Base shop';
00306
00307 $sDate = date( 'l dS of F Y h:i:s A');
00308 $sScript = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING'];
00309 $sReferer = $_SERVER['HTTP_REFERER'];
00310
00311
00312 $sWarningSubject = 'Offline warning!';
00313 $sWarningBody = "
00314 Database error in OXID eShop:
00315 Date: {$sDate}
00316 Shop: {$sFailedShop}
00317
00318 mysql error: " . $oDb->errorMsg()."
00319 mysql error no: " . $oDb->errorNo()."
00320
00321 Script: {$sScript}
00322 Referer: {$sReferer}";
00323
00324 $this->_sendMail( $sAdminEmail, $sWarningSubject, $sWarningBody );
00325 }
00326
00327
00328 $oEx = new oxConnectionException();
00329 $oEx->setMessage( 'EXCEPTION_CONNECTION_NODB' );
00330 $oEx->setConnectionError( self::_getConfigParam( '_dbUser' ) . 's' . getShopBasePath() . $oDb->errorMsg() );
00331 throw $oEx;
00332 }
00333
00342 protected function _onConnectionError( $oDb )
00343 {
00344 $sVerPrefix = '';
00345 $sVerPrefix = '_ce';
00346
00347
00348
00349 $sConfig = join( '', file( getShopBasePath().'config.inc.php' ) );
00350
00351 if ( strpos( $sConfig, '<dbHost'.$sVerPrefix.'>' ) !== false &&
00352 strpos( $sConfig, '<dbName'.$sVerPrefix.'>' ) !== false ) {
00353
00354
00355 $sHeaderCode = "HTTP/1.1 302 Found";
00356 header( $sHeaderCode );
00357 header( "Location: setup/index.php" );
00358 header( "Connection: close" );
00359 exit();
00360 } else {
00361
00362 $this->_notifyConnectionErrors( $oDb );
00363 }
00364 }
00365
00366
00374 protected function _getDbInstance( $iInstType = false )
00375 {
00376 $sHost = self::_getConfigParam( "_dbHost" );
00377 $sUser = self::_getConfigParam( "_dbUser" );
00378 $sPwd = self::_getConfigParam( "_dbPwd" );
00379 $sName = self::_getConfigParam( "_dbName" );
00380 $sType = self::_getConfigParam( "_dbType" );
00381
00382 $oDb = ADONewConnection( $sType, $this->_getModules() );
00383
00384
00385 if ( !$oDb->connect( $sHost, $sUser, $sPwd, $sName ) ) {
00386 $this->_onConnectionError( $oDb );
00387 }
00388
00389 self::_setUp( $oDb );
00390
00391 return $oDb;
00392 }
00393
00403 public static function getDb( $iFetchMode = oxDb::FETCH_MODE_NUM )
00404 {
00405 if ( defined( 'OXID_PHP_UNIT' ) ) {
00406 if ( isset( modDB::$unitMOD ) && is_object( modDB::$unitMOD ) ) {
00407 return modDB::$unitMOD;
00408 }
00409 }
00410
00411 if ( self::$_oDB === null ) {
00412
00413 $oInst = self::getInstance();
00414
00415
00416 $oInst->setConfig( oxRegistry::get("oxConfigFile") );
00417
00418 global $ADODB_SESSION_TBL,
00419 $ADODB_SESSION_CONNECT,
00420 $ADODB_SESSION_DRIVER,
00421 $ADODB_SESSION_USER,
00422 $ADODB_SESSION_PWD,
00423 $ADODB_SESSION_DB,
00424 $ADODB_SESS_LIFE,
00425 $ADODB_SESS_DEBUG;
00426
00427
00428
00429
00430
00431
00432
00433 $ADODB_SESS_LIFE = 3000 * 60;
00434 $ADODB_SESSION_TBL = "oxsessions";
00435 $ADODB_SESSION_DRIVER = self::_getConfigParam( '_dbType' );
00436 $ADODB_SESSION_USER = self::_getConfigParam( '_dbUser' );
00437 $ADODB_SESSION_PWD = self::_getConfigParam( '_dbPwd' );
00438 $ADODB_SESSION_DB = self::_getConfigParam( '_dbName' );
00439 $ADODB_SESSION_CONNECT = self::_getConfigParam( '_dbHost' );
00440 $ADODB_SESS_DEBUG = false;
00441
00442 $oDb = new oxLegacyDb();
00443 $oDbInst = $oInst->_getDbInstance();
00444 $oDb->setConnection( $oDbInst );
00445
00446 self::$_oDB = $oDb;
00447 }
00448
00449 self::$_oDB->setFetchMode( $iFetchMode );
00450
00451 return self::$_oDB;
00452 }
00453
00461 public function quoteArray( $aStrArray )
00462 {
00463 $oDb = self::getDb();
00464
00465 foreach ( $aStrArray as $sKey => $sString ) {
00466 $aStrArray[$sKey] = $oDb->quote( $sString );
00467 }
00468 return $aStrArray;
00469 }
00470
00476 public function resetTblDescCache()
00477 {
00478 self::$_aTblDescCache = array();
00479 }
00480
00488 public function getTableDescription( $sTableName )
00489 {
00490
00491 if ( isset( self::$_aTblDescCache[$sTableName] ) ) {
00492 return self::$_aTblDescCache[$sTableName];
00493 }
00494
00495 $aFields = self::getDb()->MetaColumns( $sTableName );
00496
00497 self::$_aTblDescCache[$sTableName] = $aFields;
00498
00499 return $aFields;
00500 }
00501
00511 public function convertDBDateTime( $oObject, $blToTimeStamp = false, $blOnlyDate = false )
00512 {
00513 $sDate = $oObject->value;
00514
00515
00516 $sLocalDateFormat = $this->_defineAndCheckDefaultDateValues( $blToTimeStamp );
00517 $sLocalTimeFormat = $this->_defineAndCheckDefaultTimeValues( $blToTimeStamp );
00518
00519
00520 $aDefDatePatterns = $this->_defaultDatePattern();
00521
00522
00523 $aDatePatterns = $this->_regexp2ValidateDateInput();
00524 $aTimePatterns = $this->_regexp2ValidateTimeInput();
00525
00526
00527 $aDFormats = $this->_defineDateFormattingRules();
00528 $aTFormats = $this->_defineTimeFormattingRules();
00529
00530
00531 if ( !$sDate) {
00532 $this->_setDefaultDateTimeValue($oObject, $sLocalDateFormat, $sLocalTimeFormat, $blOnlyDate);
00533 return $oObject->value;
00534 }
00535
00536 $blDefDateFound = false;
00537 $oStr = getStr();
00538
00539
00540 foreach ( array_keys( $aDefDatePatterns ) as $sDefDatePattern ) {
00541 if ( $oStr->preg_match( $sDefDatePattern, $sDate)) {
00542 $blDefDateFound = true;
00543 break;
00544 }
00545 }
00546
00547
00548 if ( $blDefDateFound) {
00549 $this->_setDefaultFormatedValue($oObject, $sDate, $sLocalDateFormat, $sLocalTimeFormat, $blOnlyDate);
00550 return $oObject->value;
00551 }
00552
00553 $blDateFound = false;
00554 $blTimeFound = false;
00555 $aDateMatches = array();
00556 $aTimeMatches = array();
00557
00558
00559 foreach ( $aDatePatterns as $sPattern => $sType) {
00560 if ( $oStr->preg_match( $sPattern, $sDate, $aDateMatches)) {
00561 $blDateFound = true;
00562
00563
00564 $sDateFormat = $aDFormats[$sLocalDateFormat][0];
00565 $aDFields = $aDFormats[$sType][1];
00566 break;
00567 }
00568 }
00569
00570
00571 if ( !$blDateFound) {
00572 return $sDate;
00573 }
00574
00575 if ( $blOnlyDate) {
00576 $this->_setDate($oObject, $sDateFormat, $aDFields, $aDateMatches);
00577 return $oObject->value;
00578 }
00579
00580
00581 foreach ( $aTimePatterns as $sPattern => $sType) {
00582 if ( $oStr->preg_match( $sPattern, $sDate, $aTimeMatches)) {
00583 $blTimeFound = true;
00584
00585
00586 $sTimeFormat = $aTFormats[$sLocalTimeFormat][0];
00587 $aTFields = $aTFormats[$sType][1];
00588
00589
00590 if ( $sType == "USA" && isset($aTimeMatches[4])) {
00591 $iIntVal = (int) $aTimeMatches[1];
00592 if ( $aTimeMatches[4] == "PM") {
00593 if ( $iIntVal < 13) {
00594 $iIntVal += 12;
00595 }
00596 } elseif ( $aTimeMatches[4] == "AM" && $aTimeMatches[1] == "12") {
00597 $iIntVal = 0;
00598 }
00599
00600 $aTimeMatches[1] = sprintf("%02d", $iIntVal);
00601 }
00602
00603 break;
00604 }
00605 }
00606
00607 if ( !$blTimeFound) {
00608
00609
00610 $this->_setDate($oObject, $sDateFormat, $aDFields, $aDateMatches);
00611 return $oObject->value;
00612 }
00613
00614 $this->_formatCorrectTimeValue($oObject, $sDateFormat, $sTimeFormat, $aDateMatches, $aTimeMatches, $aTFields, $aDFields);
00615
00616
00617 if ( !$oObject->fldmax_length) {
00618 return $this->convertDBDateTime( $oObject, $blToTimeStamp, $blOnlyDate);
00619 }
00620 return $oObject->value;
00621 }
00622
00631 public function convertDBTimestamp( $oObject, $blToTimeStamp = false )
00632 {
00633
00634 $sSQLTimeStampPattern = "/^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$/";
00635 $sISOTimeStampPattern = "/^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/";
00636 $aMatches = array();
00637 $oStr = getStr();
00638
00639
00640 if ( $blToTimeStamp) {
00641
00642 $this->convertDBDateTime( $oObject, $blToTimeStamp );
00643
00644 if ( $oStr->preg_match( $sISOTimeStampPattern, $oObject->value, $aMatches)) {
00645
00646 $oObject->setValue($aMatches[1].$aMatches[2].$aMatches[3].$aMatches[4].$aMatches[5].$aMatches[6]);
00647 $oObject->fldmax_length = strlen( $oObject->value);
00648 return $oObject->value;
00649 }
00650 } else {
00651
00652
00653
00654 if ( $oStr->preg_match( $sSQLTimeStampPattern, $oObject->value, $aMatches ) ) {
00655 $iTimestamp = mktime( $aMatches[4],
00656 $aMatches[5],
00657 $aMatches[6],
00658 $aMatches[2],
00659 $aMatches[3],
00660 $aMatches[1]);
00661 if ( !$iTimestamp ) {
00662 $iTimestamp = "0";
00663 }
00664
00665 $oObject->setValue(trim( date( "Y-m-d H:i:s", $iTimestamp)));
00666 $oObject->fldmax_length = strlen( $oObject->value);
00667 $this->convertDBDateTime( $oObject, $blToTimeStamp );
00668 return $oObject->value;
00669 }
00670 }
00671 }
00672
00681 public function convertDBDate( $oObject, $blToTimeStamp = false )
00682 {
00683 return $this->convertDBDateTime( $oObject, $blToTimeStamp, true );
00684 }
00685
00694 public function isValidFieldName( $sField )
00695 {
00696 return ( boolean ) getStr()->preg_match( "#^[\w\d\._]*$#", $sField );
00697 }
00698
00710 protected function _setDefaultFormatedValue( $oObject, $sDate, $sLocalDateFormat, $sLocalTimeFormat, $blOnlyDate )
00711 {
00712 $aDefTimePatterns = $this->_defaultTimePattern();
00713 $aDFormats = $this->_defineDateFormattingRules();
00714 $aTFormats = $this->_defineTimeFormattingRules();
00715 $oStr = getStr();
00716
00717 foreach ( array_keys( $aDefTimePatterns ) as $sDefTimePattern ) {
00718 if ( $oStr->preg_match( $sDefTimePattern, $sDate ) ) {
00719 $blDefTimeFound = true;
00720 break;
00721 }
00722 }
00723
00724
00725 if ( $blOnlyDate) {
00726 $oObject->setValue(trim( $aDFormats[$sLocalDateFormat][2] ));
00727
00728 $oObject->fldmax_length = strlen( $oObject->value );
00729 return ;
00730 } elseif ( $blDefTimeFound ) {
00731
00732 $oObject->setValue(trim( $aDFormats[$sLocalDateFormat][2] . " " . $aTFormats[$sLocalTimeFormat][2] ));
00733
00734 $oObject->fldmax_length = strlen( $oObject->value );
00735 return ;
00736 }
00737 }
00738
00746 protected function _defineAndCheckDefaultTimeValues( $blToTimeStamp )
00747 {
00748
00749
00750 $sLocalTimeFormat = self::_getConfigParam( '_sLocalTimeFormat' );
00751 if ( !$sLocalTimeFormat || $blToTimeStamp) {
00752 $sLocalTimeFormat = "ISO";
00753 }
00754 return $sLocalTimeFormat;
00755 }
00756
00764 protected function _defineAndCheckDefaultDateValues( $blToTimeStamp )
00765 {
00766
00767
00768 $sLocalDateFormat = self::_getConfigParam( '_sLocalDateFormat' );
00769 if ( !$sLocalDateFormat || $blToTimeStamp) {
00770 $sLocalDateFormat = "ISO";
00771 }
00772 return $sLocalDateFormat;
00773 }
00774
00780 protected function _defaultDatePattern()
00781 {
00782
00783 $aDefDatePatterns = array("/^0000-00-00/" => "ISO",
00784 "/^00\.00\.0000/" => "EUR",
00785 "/^00\/00\/0000/" => "USA"
00786 );
00787 return $aDefDatePatterns;
00788 }
00789
00795 protected function _defaultTimePattern()
00796 {
00797
00798 $aDefTimePatterns = array("/00:00:00$/" => "ISO",
00799 "/00\.00\.00$/" => "EUR",
00800 "/00:00:00 AM$/" => "USA"
00801 );
00802 return $aDefTimePatterns;
00803 }
00804
00810 protected function _regexp2ValidateDateInput()
00811 {
00812
00813 $aDatePatterns = array("/^([0-9]{4})-([0-9]{2})-([0-9]{2})/" => "ISO",
00814 "/^([0-9]{2})\.([0-9]{2})\.([0-9]{4})/" => "EUR",
00815 "/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})/" => "USA"
00816 );
00817 return $aDatePatterns;
00818 }
00819
00825 protected function _regexp2ValidateTimeInput()
00826 {
00827
00828 $aTimePatterns = array("/([0-9]{2}):([0-9]{2}):([0-9]{2})$/" => "ISO",
00829 "/([0-9]{2})\.([0-9]{2})\.([0-9]{2})$/" => "EUR",
00830 "/([0-9]{2}):([0-9]{2}):([0-9]{2}) ([AP]{1}[M]{1})$/" => "USA"
00831 );
00832 return $aTimePatterns;
00833 }
00834
00840 protected function _defineDateFormattingRules()
00841 {
00842
00843 $aDFormats = array("ISO" => array("Y-m-d", array(2, 3, 1), "0000-00-00"),
00844 "EUR" => array("d.m.Y", array(2, 1, 3), "00.00.0000"),
00845 "USA" => array("m/d/Y", array(1, 2, 3), "00/00/0000")
00846 );
00847 return $aDFormats;
00848 }
00849
00855 protected function _defineTimeFormattingRules()
00856 {
00857
00858 $aTFormats = array("ISO" => array("H:i:s", array(1, 2, 3 ), "00:00:00"),
00859 "EUR" => array("H.i.s", array(1, 2, 3 ), "00.00.00"),
00860 "USA" => array("h:i:s A", array(1, 2, 3 ), "00:00:00 AM")
00861 );
00862 return $aTFormats;
00863 }
00864
00875 protected function _setDefaultDateTimeValue( $oObject, $sLocalDateFormat, $sLocalTimeFormat, $blOnlyDate )
00876 {
00877 $aDFormats = $this->_defineDateFormattingRules();
00878 $aTFormats = $this->_defineTimeFormattingRules();
00879
00880 $sReturn = $aDFormats[$sLocalDateFormat][2];
00881 if ( !$blOnlyDate) {
00882 $sReturn .= " ".$aTFormats[$sLocalTimeFormat][2];
00883 }
00884
00885 if ($oObject instanceof oxField) {
00886 $oObject->setValue(trim($sReturn));
00887 } else {
00888 $oObject->value = trim($sReturn);
00889 }
00890
00891 $oObject->fldmax_length = strlen( $oObject->value);
00892 }
00893
00904 protected function _setDate( $oObject, $sDateFormat, $aDFields, $aDateMatches )
00905 {
00906
00907 $iTimestamp = mktime( 0, 0, 0, $aDateMatches[$aDFields[0]],
00908 $aDateMatches[$aDFields[1]],
00909 $aDateMatches[$aDFields[2]]);
00910
00911 if ($oObject instanceof oxField) {
00912 $oObject->setValue(@date( $sDateFormat, $iTimestamp ));
00913 } else {
00914 $oObject->value = @date( $sDateFormat, $iTimestamp );
00915 }
00916
00917 $oObject->fldmax_length = strlen( $oObject->value );
00918 }
00919
00933 protected function _formatCorrectTimeValue( $oObject, $sDateFormat, $sTimeFormat, $aDateMatches, $aTimeMatches, $aTFields, $aDFields )
00934 {
00935
00936 $iTimestamp = @mktime( (int) $aTimeMatches[$aTFields[0]],
00937 (int) $aTimeMatches[$aTFields[1]],
00938 (int) $aTimeMatches[$aTFields[2]],
00939 (int) $aDateMatches[$aDFields[0]],
00940 (int) $aDateMatches[$aDFields[1]],
00941 (int) $aDateMatches[$aDFields[2]] );
00942
00943 if ($oObject instanceof oxField) {
00944 $oObject->setValue(trim( @date( $sDateFormat." ".$sTimeFormat, $iTimestamp ) ));
00945 } else {
00946 $oObject->value = trim( @date( $sDateFormat." ".$sTimeFormat, $iTimestamp ) );
00947 }
00948
00949
00950 $oObject->fldmax_length = strlen( $oObject->value );
00951 }
00952
00958 protected function _getConnectionId()
00959 {
00960 return self::getDb()->getDb()->connectionId;
00961 }
00962
00970 public function escapeString( $sString )
00971 {
00972 if ( 'mysql' == self::_getConfigParam( "_dbType" )) {
00973 return mysql_real_escape_string( $sString, $this->_getConnectionId() );
00974 } elseif ( 'mysqli' == self::_getConfigParam( "_dbType" )) {
00975 return mysqli_real_escape_string( $this->_getConnectionId(), $sString );
00976 } else {
00977 return mysql_real_escape_string( $sString, $this->_getConnectionId() );
00978 }
00979 }
00980
00988 public function updateViews( $aTables = null )
00989 {
00990 set_time_limit(0);
00991
00992 $oShopList = oxNew("oxshoplist" );
00993 $myConfig = $oShopList->getConfig();
00994 $oShopList->selectString( "select * from oxshops");
00995
00996 $aTables = $aTables ? $aTables : $myConfig->getConfigParam( 'aMultiShopTables' );
00997 foreach ( $oShopList as $key => $oShop ) {
00998 $oShop->setMultiShopTables( $aTables );
00999 $blMultishopInherit = $myConfig->getShopConfVar( 'blMultishopInherit_oxcategories', $oShop->sOXID );
01000 $aMallInherit = array();
01001 foreach ( $aTables as $sTable ) {
01002 $aMallInherit[$sTable] = $myConfig->getShopConfVar( 'blMallInherit_' . $sTable, $oShop->sOXID );
01003 }
01004 $oShop->generateViews( $blMultishopInherit, $aMallInherit );
01005 }
01006 }
01007 }