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 $oMailer =
new phpmailer();
311 $oMailer->From = $sEmail;
312 $oMailer->AddAddress($sEmail);
313 $oMailer->Subject = $sSubject;
314 $oMailer->Body = $sBody;
316 return $oMailer->send();
327 if (($sAdminEmail = self::_getConfigParam(
'_sAdminEmail'))) {
328 $sFailedShop = isset($_REQUEST[
'shp']) ? addslashes($_REQUEST[
'shp']) :
'Base shop';
330 $sDate = date(
'l dS of F Y h:i:s A');
331 $sScript = $_SERVER[
'SCRIPT_NAME'] .
'?' . $_SERVER[
'QUERY_STRING'];
332 $sReferer = $_SERVER[
'HTTP_REFERER'];
335 $sWarningSubject =
'Offline warning!';
337 Database error in OXID eShop:
341 mysql error: " . $oDb->errorMsg() .
"
342 mysql error no: " . $oDb->errorNo() .
"
345 Referer: {$sReferer}";
347 $this->
_sendMail($sAdminEmail, $sWarningSubject, $sWarningBody);
352 $oEx->setMessage(
'EXCEPTION_CONNECTION_NODB');
353 $oEx->setConnectionError(self::_getConfigParam(
'_dbUser') .
's' . getShopBasePath() . $oDb->errorMsg());
369 $sConfig = join(
'', file(getShopBasePath() .
'config.inc.php'));
371 if (strpos($sConfig,
'<dbHost' . $sVerPrefix .
'>') !==
false &&
372 strpos($sConfig,
'<dbName' . $sVerPrefix .
'>') !==
false
376 $sHeaderCode =
"HTTP/1.1 302 Found";
377 header($sHeaderCode);
378 header(
"Location: setup/index.php");
379 header(
"Connection: close");
404 $oDb = ADONewConnection($sType, $this->
_getModules());
408 $oDb->connect($sHost, $sUser, $sPwd, $sName);
429 if (defined(
'OXID_PHP_UNIT')) {
430 if (isset(modDB::$unitMOD) && is_object(modDB::$unitMOD)) {
431 return modDB::$unitMOD;
435 if (self::$_oDB === null) {
442 global $ADODB_SESSION_TBL,
443 $ADODB_SESSION_CONNECT,
444 $ADODB_SESSION_DRIVER,
457 $ADODB_SESS_LIFE = 3000 * 60;
458 $ADODB_SESSION_TBL =
"oxsessions";
464 $ADODB_SESS_DEBUG =
false;
467 $oDbInst = $oInst->_getDbInstance();
468 $oDb->setConnection($oDbInst);
473 self::$_oDB->setFetchMode($iFetchMode);
497 self::$_aTblDescCache = array();
510 if (isset(self::$_aTblDescCache[$sTableName])) {
511 return self::$_aTblDescCache[$sTableName];
514 $aFields =
self::getDb()->MetaColumns($sTableName);
516 self::$_aTblDescCache[$sTableName] = $aFields;
531 return (
boolean )
getStr()->preg_match(
"#^[\w\d\._]*$#", $sField);
553 if (
'mysql' == self::_getConfigParam(
"_dbType")) {
555 } elseif (
'mysqli' == self::_getConfigParam(
"_dbType")) {