5 require_once getShopBasePath() .
'core/adodblite/adodb.inc.php';
162 self::$_dbType = $oConfig->getVar(
'dbType');
163 self::$_dbUser = $oConfig->getVar(
'dbUser');
164 self::$_dbPwd = $oConfig->getVar(
'dbPwd');
165 self::$_dbName = $oConfig->getVar(
'dbName');
166 self::$_dbHost = $oConfig->getVar(
'dbHost');
167 self::$_iDebug = $oConfig->getVar(
'iDebug');
168 self::$_blLogChangesInAdmin = $oConfig->getVar(
'blLogChangesInAdmin');
169 self::$_iUtfMode = $oConfig->getVar(
'iUtfMode');
170 self::$_sDefaultDatabaseConnection = $oConfig->getVar(
'sDefaultDatabaseConnection');
171 self::$_aSlaveHosts = $oConfig->getVar(
'aSlaveHosts');
173 self::$_iMasterSlaveBalance = $oConfig->getVar(
'iMasterSlaveBalance');
175 self::$_sAdminEmail = $oConfig->getVar(
'sAdminEmail');
176 self::$_sLocalTimeFormat = $oConfig->getVar(
'sLocalTimeFormat');
177 self::$_sLocalDateFormat = $oConfig->getVar(
'sLocalDateFormat');
189 if (isset(
self::$$sConfigName)) {
190 return self::$$sConfigName;
204 if (defined(
'OXID_PHP_UNIT')) {
205 self::$_instance = modInstances::getMod(__CLASS__);
208 if (!self::$_instance instanceof
oxDb) {
211 self::$_instance =
new oxDb();
213 if (defined(
'OXID_PHP_UNIT')) {
214 modInstances::addMod(__CLASS__, self::$_instance);
244 $sModules =
'perfmon';
248 if ($this->
isAdmin() && self::_getConfigParam(
'_blLogChangesInAdmin')) {
249 $sModules .= ($sModules ?
':' :
'') .
'oxadminlog';
260 global $ADODB_EXCEPTION;
261 $ADODB_EXCEPTION =
'oxAdoDbException';
263 include_once getShopBasePath() .
'core/adodblite/adodb-exceptions.inc.php';
278 $oDb->execute(
'truncate table adodb_logsql');
279 }
catch (ADODB_Exception $e) {
282 if (method_exists($oDb,
"logSQL")) {
288 $oDb->cacheSecs = 60 * 10;
289 $oDb->execute(
'SET @@session.sql_mode = ""');
291 if (self::_getConfigParam(
'_iUtfMode')) {
292 $oDb->execute(
'SET NAMES "utf8"');
293 $oDb->execute(
'SET CHARACTER SET utf8');
294 $oDb->execute(
'SET CHARACTER_SET_CONNECTION = utf8');
295 $oDb->execute(
'SET CHARACTER_SET_DATABASE = utf8');
296 $oDb->execute(
'SET character_set_results = utf8');
297 $oDb->execute(
'SET character_set_server = utf8');
298 } elseif (($sConn = self::_getConfigParam(
'_sDefaultDatabaseConnection')) !=
'') {
299 $oDb->execute(
'SET NAMES "' . $sConn .
'"');
312 protected function _sendMail($sEmail, $sSubject, $sBody)
314 include_once getShopBasePath() .
'core/phpmailer/class.phpmailer.php';
315 include_once getShopBasePath() .
'core/phpmailer/class.smtp.php';
316 $oMailer =
new phpmailer();
319 $oMailer->From = $sEmail;
320 $oMailer->AddAddress($sEmail);
321 $oMailer->Subject = $sSubject;
322 $oMailer->Body = $sBody;
324 return $oMailer->send();
335 if (($sAdminEmail = self::_getConfigParam(
'_sAdminEmail'))) {
336 $sFailedShop = isset($_REQUEST[
'shp']) ? addslashes($_REQUEST[
'shp']) :
'Base shop';
338 $sDate = date(
'l dS of F Y h:i:s A');
339 $sScript = $_SERVER[
'SCRIPT_NAME'] .
'?' . $_SERVER[
'QUERY_STRING'];
340 $sReferer = $_SERVER[
'HTTP_REFERER'];
343 $sWarningSubject =
'Offline warning!';
345 Database error in OXID eShop:
349 mysql error: " . $oDb->errorMsg() .
"
350 mysql error no: " . $oDb->errorNo() .
"
353 Referer: {$sReferer}";
355 $this->
_sendMail($sAdminEmail, $sWarningSubject, $sWarningBody);
360 $oEx->setMessage(
'EXCEPTION_CONNECTION_NODB');
361 $oEx->setConnectionError(self::_getConfigParam(
'_dbUser') .
's' . getShopBasePath() . $oDb->errorMsg());
377 $sConfig = join(
'', file(getShopBasePath() .
'config.inc.php'));
379 if (strpos($sConfig,
'<dbHost' . $sVerPrefix .
'>') !==
false &&
380 strpos($sConfig,
'<dbName' . $sVerPrefix .
'>') !==
false
384 $sHeaderCode =
"HTTP/1.1 302 Found";
385 header($sHeaderCode);
386 header(
"Location: setup/index.php");
387 header(
"Connection: close");
412 $oDb = ADONewConnection($sType, $this->
_getModules());
416 $oDb->connect($sHost, $sUser, $sPwd, $sName);
437 if (defined(
'OXID_PHP_UNIT')) {
438 if (isset(modDB::$unitMOD) && is_object(modDB::$unitMOD)) {
439 return modDB::$unitMOD;
443 if (self::$_oDB === null) {
452 global $ADODB_SESSION_TBL,
453 $ADODB_SESSION_CONNECT,
454 $ADODB_SESSION_DRIVER,
467 $ADODB_SESS_LIFE = 3000 * 60;
468 $ADODB_SESSION_TBL =
"oxsessions";
474 $ADODB_SESS_DEBUG =
false;
479 $oDbInst = $oInst->_getDbInstance();
480 $oDb->setConnection($oDbInst);
485 self::$_oDB->setFetchMode($iFetchMode);
511 self::$_aTblDescCache = array();
524 if (isset(self::$_aTblDescCache[$sTableName])) {
525 return self::$_aTblDescCache[$sTableName];
528 $aFields =
self::getDb()->MetaColumns($sTableName);
530 self::$_aTblDescCache[$sTableName] = $aFields;
547 return (
boolean )
getStr()->preg_match(
"#^[\w\d\._]*$#", $sField);
572 if (
'mysql' == self::_getConfigParam(
"_dbType")) {
574 } elseif (
'mysqli' == self::_getConfigParam(
"_dbType")) {