5 require_once getShopBasePath() .
'core/adodblite/adodb.inc.php';
160 self::$_dbType = $oConfig->getVar(
'dbType');
161 self::$_dbUser = $oConfig->getVar(
'dbUser');
162 self::$_dbPwd = $oConfig->getVar(
'dbPwd');
163 self::$_dbName = $oConfig->getVar(
'dbName');
164 self::$_dbHost = $oConfig->getVar(
'dbHost');
165 self::$_iDebug = $oConfig->getVar(
'iDebug');
166 self::$_blLogChangesInAdmin = $oConfig->getVar(
'blLogChangesInAdmin');
167 self::$_iUtfMode = $oConfig->getVar(
'iUtfMode');
168 self::$_sDefaultDatabaseConnection = $oConfig->getVar(
'sDefaultDatabaseConnection');
169 self::$_aSlaveHosts = $oConfig->getVar(
'aSlaveHosts');
170 self::$_iMasterSlaveBalance = $oConfig->getVar(
'iMasterSlaveBalance');
171 self::$_sAdminEmail = $oConfig->getVar(
'sAdminEmail');
172 self::$_sLocalTimeFormat = $oConfig->getVar(
'sLocalTimeFormat');
173 self::$_sLocalDateFormat = $oConfig->getVar(
'sLocalDateFormat');
185 if (isset(
self::$$sConfigName)) {
186 return self::$$sConfigName;
200 if (defined(
'OXID_PHP_UNIT')) {
201 self::$_instance = modInstances::getMod(__CLASS__);
204 if (!self::$_instance instanceof
oxDb) {
207 self::$_instance =
new oxDb();
209 if (defined(
'OXID_PHP_UNIT')) {
210 modInstances::addMod(__CLASS__, self::$_instance);
240 $sModules =
'perfmon';
244 if ($this->
isAdmin() && self::_getConfigParam(
'_blLogChangesInAdmin')) {
245 $sModules .= ($sModules ?
':' :
'') .
'oxadminlog';
256 global $ADODB_EXCEPTION;
257 $ADODB_EXCEPTION =
'oxAdoDbException';
259 include_once getShopBasePath() .
'core/adodblite/adodb-exceptions.inc.php';
272 $oDb->execute(
'truncate table adodb_logsql');
273 }
catch (ADODB_Exception $e) {
276 if (method_exists($oDb,
"logSQL")) {
281 $oDb->cacheSecs = 60 * 10;
282 $oDb->execute(
'SET @@session.sql_mode = ""');
284 if (self::_getConfigParam(
'_iUtfMode')) {
285 $oDb->execute(
'SET NAMES "utf8"');
286 $oDb->execute(
'SET CHARACTER SET utf8');
287 $oDb->execute(
'SET CHARACTER_SET_CONNECTION = utf8');
288 $oDb->execute(
'SET CHARACTER_SET_DATABASE = utf8');
289 $oDb->execute(
'SET character_set_results = utf8');
290 $oDb->execute(
'SET character_set_server = utf8');
291 } elseif (($sConn = self::_getConfigParam(
'_sDefaultDatabaseConnection')) !=
'') {
292 $oDb->execute(
'SET NAMES "' . $sConn .
'"');
305 protected function _sendMail($sEmail, $sSubject, $sBody)
307 include_once getShopBasePath() .
'core/phpmailer/class.phpmailer.php';
308 include_once getShopBasePath() .
'core/phpmailer/class.smtp.php';
309 $oMailer =
new phpmailer();
312 $oMailer->From = $sEmail;
313 $oMailer->AddAddress($sEmail);
314 $oMailer->Subject = $sSubject;
315 $oMailer->Body = $sBody;
317 return $oMailer->send();
328 if (($sAdminEmail = self::_getConfigParam(
'_sAdminEmail'))) {
329 $sFailedShop = isset($_REQUEST[
'shp']) ? addslashes($_REQUEST[
'shp']) :
'Base shop';
331 $sDate = date(
'l dS of F Y h:i:s A');
332 $sScript = $_SERVER[
'SCRIPT_NAME'] .
'?' . $_SERVER[
'QUERY_STRING'];
333 $sReferer = $_SERVER[
'HTTP_REFERER'];
336 $sWarningSubject =
'Offline warning!';
338 Database error in OXID eShop:
342 mysql error: " . $oDb->errorMsg() .
"
343 mysql error no: " . $oDb->errorNo() .
"
346 Referer: {$sReferer}";
348 $this->
_sendMail($sAdminEmail, $sWarningSubject, $sWarningBody);
353 $oEx->setMessage(
'EXCEPTION_CONNECTION_NODB');
354 $oEx->setConnectionError(self::_getConfigParam(
'_dbUser') .
's' . getShopBasePath() . $oDb->errorMsg());
370 $sConfig = join(
'', file(getShopBasePath() .
'config.inc.php'));
372 if (strpos($sConfig,
'<dbHost' . $sVerPrefix .
'>') !==
false &&
373 strpos($sConfig,
'<dbName' . $sVerPrefix .
'>') !==
false
377 $sHeaderCode =
"HTTP/1.1 302 Found";
378 header($sHeaderCode);
379 header(
"Location: setup/index.php");
380 header(
"Connection: close");
405 $oDb = ADONewConnection($sType, $this->
_getModules());
409 $oDb->connect($sHost, $sUser, $sPwd, $sName);
430 if (defined(
'OXID_PHP_UNIT')) {
431 if (isset(modDB::$unitMOD) && is_object(modDB::$unitMOD)) {
432 return modDB::$unitMOD;
436 if (self::$_oDB === null) {
443 global $ADODB_SESSION_TBL,
444 $ADODB_SESSION_CONNECT,
445 $ADODB_SESSION_DRIVER,
458 $ADODB_SESS_LIFE = 3000 * 60;
459 $ADODB_SESSION_TBL =
"oxsessions";
465 $ADODB_SESS_DEBUG =
false;
468 $oDbInst = $oInst->_getDbInstance();
469 $oDb->setConnection($oDbInst);
474 self::$_oDB->setFetchMode($iFetchMode);
498 self::$_aTblDescCache = array();
511 if (isset(self::$_aTblDescCache[$sTableName])) {
512 return self::$_aTblDescCache[$sTableName];
515 $aFields =
self::getDb()->MetaColumns($sTableName);
517 self::$_aTblDescCache[$sTableName] = $aFields;
532 return (
boolean )
getStr()->preg_match(
"#^[\w\d\._]*$#", $sField);
554 if (
'mysql' == self::_getConfigParam(
"_dbType")) {
556 } elseif (
'mysqli' == self::_getConfigParam(
"_dbType")) {