/** * Set transaction isolation level * Allowed values READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE * * @param string $sLevel level * * @return null */ public static function setTransactionIsolationLevel($sLevel = null) { $aLevels = array('READ UNCOMMITTED', 'READ COMMITTED', 'REPEATABLE READ', 'SERIALIZABLE'); if (in_array(strtoupper($sLevel), $aLevels)) { self::$_oDB->execute('SET TRANSACTION ISOLATION LEVEL ' . $sLevel); } }
/** * Returns database object * * @param int $iFetchMode - fetch mode default numeric - 0 * * @throws oxConnectionException error while initiating connection to DB * * @return oxLegacyDb */ public static function getDb($iFetchMode = oxDb::FETCH_MODE_NUM) { if (defined('OXID_PHP_UNIT')) { if (isset(modDB::$unitMOD) && is_object(modDB::$unitMOD)) { return modDB::$unitMOD; } } if (self::$_oDB === null) { $oInst = self::getInstance(); //setting configuration on the first call $oInst->setConfig(oxRegistry::get("oxConfigFile")); global $ADODB_SESSION_TBL, $ADODB_SESSION_CONNECT, $ADODB_SESSION_DRIVER, $ADODB_SESSION_USER, $ADODB_SESSION_PWD, $ADODB_SESSION_DB, $ADODB_SESS_LIFE, $ADODB_SESS_DEBUG; // session related parameters. don't change. //Tomas //the default setting is 3000 * 60, but actually changing this will give no effect as now redefinition of this constant //appears after OXID custom settings are loaded and $ADODB_SESS_LIFE depends on user settings. //You can find the redefinition of ADODB_SESS_LIFE @ oxconfig.php:: line ~ 390. $ADODB_SESS_LIFE = 3000 * 60; $ADODB_SESSION_TBL = "oxsessions"; $ADODB_SESSION_DRIVER = self::_getConfigParam('_dbType'); $ADODB_SESSION_USER = self::_getConfigParam('_dbUser'); $ADODB_SESSION_PWD = self::_getConfigParam('_dbPwd'); $ADODB_SESSION_DB = self::_getConfigParam('_dbName'); $ADODB_SESSION_CONNECT = self::_getConfigParam('_dbHost'); $ADODB_SESS_DEBUG = false; $oDb = new oxLegacyDb(); $oDbInst = $oInst->_getDbInstance(); $oDb->setConnection($oDbInst); self::$_oDB = $oDb; } self::$_oDB->setFetchMode($iFetchMode); return self::$_oDB; }
protected function _zw_getFromVariant() { if ($this->_oFromVariant === null && $this->isRangePrice()) { $this->_oFromVariant = false; $sPriceSuffix = $this->_getUserPriceSufix(); $dVarMinPrice = $this->_getVarMinPrice(); $dPrice = $this->_getPrice(); if ($dVarMinPrice !== null && $dPrice > $dVarMinPrice) { $sSql = 'SELECT oxid '; $sSql .= ' FROM ' . $this->getViewName(true) . ' WHERE ' . $this->getSqlActiveSnippet(true) . ' AND ( `oxparentid` = ' . oxDb::getDb()->quote($this->getId()) . ' ) AND (`oxprice' . $sPriceSuffix . '` = ' . oxDb::getDb()->quote($dVarMinPrice) . ' ) Limit 1'; $sOxid = oxdb::getDb()->getOne($sSql); $oVariant = oxnew('oxarticle'); if ($sOxid && $oVariant->load($sOxid)) { $this->_oFromVariant = $oVariant; } } } return $this->_oFromVariant; }
/** * Generates search string for similar list. * * @param string $sArticleTable Article table name * @param array $aList A list of original articles * * @return string */ protected function _generateSimListSearchStr($sArticleTable, $aList) { $sFieldList = $this->getSelectFields(); $aList = array_slice($aList, 0, $this->getConfig()->getConfigParam('iNrofSimilarArticles')); $sSearch = "select {$sFieldList} from {$sArticleTable} where " . $this->getSqlActiveSnippet() . " and {$sArticleTable}.oxissearch = 1 and {$sArticleTable}.oxid in ( "; $sSearch .= implode(',', oxdb::getDb()->quoteArray($aList)) . ')'; // #524A -- randomizing articles in attribute list $sSearch .= ' order by rand() '; return $sSearch; }
<?php require_once dirname(__FILE__) . "/bootstrap.php"; $oDb = oxdb::getDb(); //DELETE ALL ARTICLES $sql = "SELECT oxid FROM oxarticles WHERE oxparentid = ''"; $rs = $oDb->select($sql); if ($rs != false && $rs->recordCount() > 0) { while (!$rs->EOF) { $oArticle = oxNew("oxArticle"); echo "Article " . $rs->fields[0] . " deleted<br />"; $oArticle->setId($rs->fields[0]); $oArticle->delete(); $rs->moveNext(); } } //DELETE ALL CATEGORIES $sql = "SELECT oxid FROM oxcategories"; $rs = $oDb->select($sql); if ($rs != false && $rs->recordCount() > 0) { while (!$rs->EOF) { $oCat = oxNew("oxCategory"); echo "Category " . $rs->fields[0] . " deleted<br />"; $oCat->load($rs->fields[0]); $oCat->delete(); $rs->moveNext(); } } //DELETE ALL ATTRIBUTES $sql = "SELECT oxid FROM oxattribute"; $rs = $oDb->select($sql);
public function DoValidate() { $tmpl = new XTC2OXIDUI_Template(XTC2OXIDUI_BASEDIR . '/tmpl/step1.html'); $set = $this->GetSettingsFromRequest(); $this->SetSettings($tmpl, $set); $tmpl->Set('{STATUS}', ''); $errors = array(); $imgdir = $this->Filter($set['oxid-xtc-imgdir']); if (false == is_dir($imgdir)) { array_push($errors, 'Invalid XTC Image Directory: ' . $imgdir); } $oxiddir = $this->Filter($set['oxid-install-dir']); if (false == is_dir($oxiddir)) { array_push($errors, 'Invalid OXID Directory: ' . $oxiddir); } else { $this->InitOxid($oxiddir); global $myConfig; $myConfig = oxRegistry::getConfig(); #$user = oxSession::getVariable('usr'); #if (strpos($user, 'admin') === false) { # array_push($errors, 'You have to be logged in as an administrator in the shop front-end in order to use the importer!'); #} try { $oxDB = oxdb::getDb(true); $sql = 'SELECT COUNT(*) FROM ' . $set['oxid-xtc-db'] . '.products'; $oxDB->Execute($sql); $error = $oxDB->ErrorMsg(); if ($error) { array_push($errors, 'Invalid XTC Database: ' . $set['oxid-xtc-db']); } } catch (oxConnectionException $e) { array_push($errors, $e->getMessage()); } } if (count($errors) > 0) { $html = '<b>Error!</b><ul>'; foreach ($errors as $e) { $html .= '<li>' . $e . '</li>'; } $html .= '</ul>'; $tmpl->Set('{STATUS}', $html); } else { $step2 = new XTC2OXIDUI_Template(XTC2OXIDUI_BASEDIR . '/tmpl/step2.html'); $tmpl->Set('{STATUS}', $step2->Render()); $_SESSION['xtc2oxidui'] = $set; } echo $tmpl->Render(); }