5 require_once getShopBasePath() .
'core/adodblite/adodb.inc.php';
144 self::$_dbType = $oConfig->getVar(
'dbType' );
145 self::$_dbUser = $oConfig->getVar(
'dbUser' );
146 self::$_dbPwd = $oConfig->getVar(
'dbPwd' );
147 self::$_dbName = $oConfig->getVar(
'dbName' );
148 self::$_dbHost = $oConfig->getVar(
'dbHost' );
149 self::$_iDebug = $oConfig->getVar(
'iDebug' );
150 self::$_blLogChangesInAdmin = $oConfig->getVar(
'blLogChangesInAdmin' );
151 self::$_iUtfMode = $oConfig->getVar(
'iUtfMode' );
152 self::$_sDefaultDatabaseConnection = $oConfig->getVar(
'sDefaultDatabaseConnection' );
153 self::$_aSlaveHosts = $oConfig->getVar(
'aSlaveHosts' );
154 self::$_iMasterSlaveBalance = $oConfig->getVar(
'iMasterSlaveBalance' );
155 self::$_sAdminEmail = $oConfig->getVar(
'sAdminEmail' );
156 self::$_sLocalTimeFormat = $oConfig->getVar(
'sLocalTimeFormat' );
157 self::$_sLocalDateFormat = $oConfig->getVar(
'sLocalDateFormat' );
169 if ( isset(
self::$$sConfigName ) ) {
170 return self::$$sConfigName;
184 if ( defined(
'OXID_PHP_UNIT' ) ) {
185 self::$_instance = modInstances::getMod( __CLASS__ );
188 if ( !self::$_instance instanceof
oxDb ) {
191 self::$_instance =
new oxDb();
193 if ( defined(
'OXID_PHP_UNIT' ) ) {
194 modInstances::addMod( __CLASS__, self::$_instance);
220 global $ADODB_EXCEPTION;
221 $ADODB_EXCEPTION =
'oxAdoDbException';
222 include_once getShopBasePath() .
'core/adodblite/adodb-exceptions.inc.php';
226 $sModules =
'perfmon';
230 if ( $this->
isAdmin() && self::_getConfigParam(
'_blLogChangesInAdmin' ) ) {
231 $sModules .= ( $sModules ?
':' :
'' ) .
'oxadminlog';
249 $oDb->execute(
'truncate table adodb_logsql' );
250 }
catch ( ADODB_Exception $e ) {
253 if ( method_exists( $oDb,
"logSQL" ) ) {
254 $oDb->logSQL(
true );
258 $oDb->cacheSecs = 60 * 10;
259 $oDb->execute(
'SET @@session.sql_mode = ""' );
261 if ( self::_getConfigParam(
'_iUtfMode' ) ) {
262 $oDb->execute(
'SET NAMES "utf8"' );
263 $oDb->execute(
'SET CHARACTER SET utf8' );
264 $oDb->execute(
'SET CHARACTER_SET_CONNECTION = utf8' );
265 $oDb->execute(
'SET CHARACTER_SET_DATABASE = utf8' );
266 $oDb->execute(
'SET character_set_results = utf8' );
267 $oDb->execute(
'SET character_set_server = utf8' );
268 } elseif ( ( $sConn = self::_getConfigParam(
'_sDefaultDatabaseConnection') ) !=
'' ) {
269 $oDb->execute(
'SET NAMES "' . $sConn .
'"' );
282 protected function _sendMail( $sEmail, $sSubject, $sBody )
284 include_once getShopBasePath() .
'core/phpmailer/class.phpmailer.php';
285 $oMailer =
new phpmailer();
288 $oMailer->From = $sEmail;
289 $oMailer->AddAddress( $sEmail );
290 $oMailer->Subject = $sSubject;
291 $oMailer->Body = $sBody;
292 return $oMailer->send();
305 if ( ( $sAdminEmail = self::_getConfigParam(
'_sAdminEmail' ) ) ) {
306 $sFailedShop = isset( $_REQUEST[
'shp'] ) ? addslashes( $_REQUEST[
'shp'] ) :
'Base shop';
308 $sDate = date(
'l dS of F Y h:i:s A');
309 $sScript = $_SERVER[
'SCRIPT_NAME'] .
'?' . $_SERVER[
'QUERY_STRING'];
310 $sReferer = $_SERVER[
'HTTP_REFERER'];
313 $sWarningSubject =
'Offline warning!';
315 Database error in OXID eShop:
319 mysql error: " . $oDb->errorMsg().
"
320 mysql error no: " . $oDb->errorNo().
"
323 Referer: {$sReferer}";
325 $this->
_sendMail( $sAdminEmail, $sWarningSubject, $sWarningBody );
330 $oEx->setMessage(
'EXCEPTION_CONNECTION_NODB' );
331 $oEx->setConnectionError( self::_getConfigParam(
'_dbUser' ) .
's' . getShopBasePath() . $oDb->errorMsg() );
350 $sConfig = join(
'', file( getShopBasePath().
'config.inc.php' ) );
352 if ( strpos( $sConfig,
'<dbHost'.$sVerPrefix.
'>' ) !==
false &&
353 strpos( $sConfig,
'<dbName'.$sVerPrefix.
'>' ) !==
false ) {
356 $sHeaderCode =
"HTTP/1.1 302 Found";
357 header( $sHeaderCode );
358 header(
"Location: setup/index.php" );
359 header(
"Connection: close" );
384 $oDb = ADONewConnection( $sType, $this->
_getModules() );
388 $oDb->connect( $sHost, $sUser, $sPwd, $sName );
409 if ( defined(
'OXID_PHP_UNIT' ) ) {
410 if ( isset( modDB::$unitMOD ) && is_object( modDB::$unitMOD ) ) {
411 return modDB::$unitMOD;
415 if ( self::$_oDB === null ) {
422 global $ADODB_SESSION_TBL,
423 $ADODB_SESSION_CONNECT,
424 $ADODB_SESSION_DRIVER,
437 $ADODB_SESS_LIFE = 3000 * 60;
438 $ADODB_SESSION_TBL =
"oxsessions";
444 $ADODB_SESS_DEBUG =
false;
447 $oDbInst = $oInst->_getDbInstance();
448 $oDb->setConnection( $oDbInst );
453 self::$_oDB->setFetchMode( $iFetchMode );
469 foreach ( $aStrArray as $sKey => $sString ) {
470 $aStrArray[$sKey] = $oDb->quote( $sString );
482 self::$_aTblDescCache = array();
495 if ( isset( self::$_aTblDescCache[$sTableName] ) ) {
496 return self::$_aTblDescCache[$sTableName];
499 $aFields =
self::getDb()->MetaColumns( $sTableName );
501 self::$_aTblDescCache[$sTableName] = $aFields;
519 return oxRegistry::get(
'oxUtilsDate')->convertDBDateTime( $oObject, $blToTimeStamp, $blOnlyDate );
534 return oxRegistry::get(
'oxUtilsDate')->convertDBTimestamp( $oObject, $blToTimeStamp );
549 return oxRegistry::get(
'oxUtilsDate')->convertDBDate( $oObject, $blToTimeStamp );
562 return (
boolean )
getStr()->preg_match(
"#^[\w\d\._]*$#", $sField );
662 $aDFormats = array(
"ISO" => array(
"Y-m-d", array(2, 3, 1),
"0000-00-00"),
663 "EUR" => array(
"d.m.Y", array(2, 1, 3),
"00.00.0000"),
664 "USA" => array(
"m/d/Y", array(1, 2, 3),
"00/00/0000")
679 $aTFormats = array(
"ISO" => array(
"H:i:s", array(1, 2, 3 ),
"00:00:00"),
680 "EUR" => array(
"H.i.s", array(1, 2, 3 ),
"00.00.00"),
681 "USA" => array(
"h:i:s A", array(1, 2, 3 ),
"00:00:00 AM")
703 $sReturn = $aDFormats[$sLocalDateFormat][2];
705 $sReturn .=
" ".$aTFormats[$sLocalTimeFormat][2];
708 if ($oObject instanceof
oxField) {
709 $oObject->setValue(trim($sReturn));
711 $oObject->value = trim($sReturn);
714 $oObject->fldmax_length = strlen( $oObject->value);
729 protected function _setDate( $oObject, $sDateFormat, $aDFields, $aDateMatches )
732 $iTimestamp = mktime( 0, 0, 0, $aDateMatches[$aDFields[0]],
733 $aDateMatches[$aDFields[1]],
734 $aDateMatches[$aDFields[2]]);
736 if ($oObject instanceof
oxField) {
737 $oObject->setValue(@date( $sDateFormat, $iTimestamp ));
739 $oObject->value = @date( $sDateFormat, $iTimestamp );
742 $oObject->fldmax_length = strlen( $oObject->value );
760 protected function _formatCorrectTimeValue( $oObject, $sDateFormat, $sTimeFormat, $aDateMatches, $aTimeMatches, $aTFields, $aDFields )
763 $iTimestamp = @mktime( (
int) $aTimeMatches[$aTFields[0]],
764 (
int) $aTimeMatches[$aTFields[1]],
765 (
int) $aTimeMatches[$aTFields[2]],
766 (
int) $aDateMatches[$aDFields[0]],
767 (
int) $aDateMatches[$aDFields[1]],
768 (
int) $aDateMatches[$aDFields[2]] );
770 if ($oObject instanceof
oxField) {
771 $oObject->setValue(trim( @date( $sDateFormat.
" ".$sTimeFormat, $iTimestamp ) ));
773 $oObject->value = trim( @date( $sDateFormat.
" ".$sTimeFormat, $iTimestamp ) );
777 $oObject->fldmax_length = strlen( $oObject->value );
799 if (
'mysql' == self::_getConfigParam(
"_dbType" )) {
801 } elseif (
'mysqli' == self::_getConfigParam(
"_dbType" )) {
819 $oMetaData =
oxNew(
'oxDbMetaDataHandler');
820 return $oMetaData->updateViews();