source/Core/SeoEncoder.php
protected function _loadFromDb($sType, $sId, $iLang, $iShopId = null, $sParams = null, $blStrictParamsCheck = true)
    {

        if ($iShopId === null) {
            $iShopId = \OxidEsales\Eshop\Core\Registry::getConfig()->getShopId();
        }

        $iLang = (int) $iLang;
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC);

        $sQ = "
            SELECT
                `oxfixed`,
                `oxseourl`,
                `oxexpired`,
                `oxtype`
            FROM `oxseo`
            WHERE `oxtype` = " . $oDb->quote($sType) . "
               AND `oxobjectid` = " . $oDb->quote($sId) . "
               AND `oxshopid` = " . $oDb->quote($iShopId) . "
               AND `oxlang` = '{$iLang}'";

        $sParams = $sParams ? $sParams : '';
        if ($sParams && $blStrictParamsCheck) {
            $sQ .= " AND `oxparams` = '{$sParams}'";
        } else {
            $sQ .= " ORDER BY `oxparams` ASC";
        }
        $sQ .= " LIMIT 1";


        // caching to avoid same queries..
        $sIdent = md5($sQ);

        // looking in cache
        if (($sSeoUrl = $this->_loadFromCache($sIdent, $sType, $iLang, $iShopId, $sParams)) === false) {
            $oRs = $oDb->select($sQ);

            if ($oRs && $oRs->count() > 0 && !$oRs->EOF) {
                // moving expired static urls to history ..
                if ($oRs->fields['oxexpired'] && ($oRs->fields['oxtype'] == 'static' || $oRs->fields['oxtype'] == 'dynamic')) {
                    // if expired - copying to history, marking as not expired
                    $this->_copyToHistory($sId, $iShopId, $iLang);
                    $oDb->execute(
                        "update oxseo set oxexpired = 0 where oxobjectid = ? and oxlang = ? and oxshopid = ?",
                        [$sId, $iLang, $iShopId]
                    );
                    $sSeoUrl = $oRs->fields['oxseourl'];
                } elseif (!$oRs->fields['oxexpired'] || $oRs->fields['oxfixed']) {
                    // if seo url is available and is valid
                    $sSeoUrl = $oRs->fields['oxseourl'];
                }

                // storing in cache
                $this->_saveInCache($sIdent, $sSeoUrl, $sType, $iLang, $iShopId, $sParams);
            }
        }

        return $sSeoUrl;
    }
protected function _loadFromDb($sType, $sId, $iLang, $iShopId = null, $sParams = null, $blStrictParamsCheck = true)
    {

        if ($iShopId === null) {
            $iShopId = \OxidEsales\Eshop\Core\Registry::getConfig()->getShopId();
        }

        $iLang = (int) $iLang;
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC);

        $sQ = "
            SELECT
                `oxfixed`,
                `oxseourl`,
                `oxexpired`,
                `oxtype`
            FROM `oxseo`
            WHERE `oxtype` = " . $oDb->quote($sType) . "
               AND `oxobjectid` = " . $oDb->quote($sId) . "
               AND `oxshopid` = " . $oDb->quote($iShopId) . "
               AND `oxlang` = '{$iLang}'";

        $sParams = $sParams ? $sParams : '';
        if ($sParams && $blStrictParamsCheck) {
            $sQ .= " AND `oxparams` = '{$sParams}'";
        } else {
            $sQ .= " ORDER BY `oxparams` ASC";
        }
        $sQ .= " LIMIT 1";


        // caching to avoid same queries..
        $sIdent = md5($sQ);

        // looking in cache
        if (($sSeoUrl = $this->_loadFromCache($sIdent, $sType, $iLang, $iShopId, $sParams)) === false) {
            $oRs = $oDb->select($sQ);

            if ($oRs && $oRs->count() > 0 && !$oRs->EOF) {
                // moving expired static urls to history ..
                if ($oRs->fields['oxexpired'] && ($oRs->fields['oxtype'] == 'static' || $oRs->fields['oxtype'] == 'dynamic')) {
                    // if expired - copying to history, marking as not expired
                    $this->_copyToHistory($sId, $iShopId, $iLang);
                    $oDb->execute(
                        "update oxseo set oxexpired = 0 where oxobjectid = ? and oxlang = ? and oxshopid = ?",
                        [$sId, $iLang, $iShopId]
                    );
                    $sSeoUrl = $oRs->fields['oxseourl'];
                } elseif (!$oRs->fields['oxexpired'] || $oRs->fields['oxfixed']) {
                    // if seo url is available and is valid
                    $sSeoUrl = $oRs->fields['oxseourl'];
                }

                // storing in cache
                $this->_saveInCache($sIdent, $sSeoUrl, $sType, $iLang, $iShopId, $sParams);
            }
        }

        return $sSeoUrl;
    }
protected function _loadFromDb ( $ sType , $ sId , $ iLang , $ iShopId = null , $ sParams = null , $ blStrictParamsCheck = true ) { if ( $ iShopId === null ) { $ iShopId = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getShopId ( ) ; } $ iLang = ( int ) $ iLang ; $ oDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: FETCH_MODE_ASSOC ) ; $ sQ = "
            SELECT
                `oxfixed`,
                `oxseourl`,
                `oxexpired`,
                `oxtype`
            FROM `oxseo`
            WHERE `oxtype` = " . $ oDb -> quote ( $ sType ) . "
               AND `oxobjectid` = " . $ oDb -> quote ( $ sId ) . "
               AND `oxshopid` = " . $ oDb -> quote ( $ iShopId ) . "
               AND `oxlang` = '{$iLang}'" ; $ sParams = $ sParams ? $ sParams : '' ; if ( $ sParams && $ blStrictParamsCheck ) { $ sQ .= " AND `oxparams` = '{$sParams}'" ; } else { $ sQ .= " ORDER BY `oxparams` ASC" ; } $ sQ .= " LIMIT 1" ; // caching to avoid same queries.. $ sIdent = md5 ( $ sQ ) ; // looking in cache if ( ( $ sSeoUrl = $ this -> _loadFromCache ( $ sIdent , $ sType , $ iLang , $ iShopId , $ sParams ) ) === false ) { $ oRs = $ oDb -> select ( $ sQ ) ; if ( $ oRs && $ oRs -> count ( ) > 0 && ! $ oRs -> EOF ) { // moving expired static urls to history .. if ( $ oRs -> fields [ 'oxexpired' ] && ( $ oRs -> fields [ 'oxtype' ] == 'static' || $ oRs -> fields [ 'oxtype' ] == 'dynamic' ) ) { // if expired - copying to history, marking as not expired $ this -> _copyToHistory ( $ sId , $ iShopId , $ iLang ) ; $ oDb -> execute ( "update oxseo set oxexpired = 0 where oxobjectid = ? and oxlang = ? and oxshopid = ?" , [ $ sId , $ iLang , $ iShopId ] ) ; $ sSeoUrl = $ oRs -> fields [ 'oxseourl' ] ; } elseif ( ! $ oRs -> fields [ 'oxexpired' ] || $ oRs -> fields [ 'oxfixed' ] ) { // if seo url is available and is valid $ sSeoUrl = $ oRs -> fields [ 'oxseourl' ] ; } // storing in cache $ this -> _saveInCache ( $ sIdent , $ sSeoUrl , $ sType , $ iLang , $ iShopId , $ sParams ) ; } } return $ sSeoUrl ; }
_loadFromDb loads data from oxseo table if exists
returns oxseo url

@param string $sType               object type
@param string $sId                 object identifier
@param int    $iLang               active language id
@param mixed  $iShopId             active shop id
@param string $sParams             additional seo params. optional (mostly used for db indexing)
@param bool   $blStrictParamsCheck strict parameters check

@access         protected

@return string || false
_loadFromDb loads data from oxseo table if exists returns oxseo url