protected static function replace_sql_legacy($selectwhere, array $params, $sort = '') {
        // Following mapping is done to make can_delete_course() compatible with legacy store.
        if ($selectwhere == "userid = :userid AND courseid = :courseid AND eventname = :eventname AND timecreated > :since" and
                empty($sort)) {
            $replace = "module = 'course' AND action = 'new' AND userid = :userid AND url = :url AND time > :since";
            $params += array('url' => "view.php?id={$params['courseid']}");
            return array($replace, $params, $sort);
        }

        // Replace db field names to make it compatible with legacy log.
        foreach (self::$standardtolegacyfields as $from => $to) {
            $selectwhere = str_replace($from, $to, $selectwhere);
            if (!empty($sort)) {
                $sort = str_replace($from, $to, $sort);
            }
            if (isset($params[$from])) {
                $params[$to] = $params[$from];
                unset($params[$from]);
            }
        }

        // Replace crud fields.
        $selectwhere = preg_replace_callback("/(crud).*?(<>|=|!=).*?'(.*?)'/s", 'self::replace_crud', $selectwhere);

        return array($selectwhere, $params, $sort);
    }
protected static function replace_sql_legacy($selectwhere, array $params, $sort = '') {
        // Following mapping is done to make can_delete_course() compatible with legacy store.
        if ($selectwhere == "userid = :userid AND courseid = :courseid AND eventname = :eventname AND timecreated > :since" and
                empty($sort)) {
            $replace = "module = 'course' AND action = 'new' AND userid = :userid AND url = :url AND time > :since";
            $params += array('url' => "view.php?id={$params['courseid']}");
            return array($replace, $params, $sort);
        }

        // Replace db field names to make it compatible with legacy log.
        foreach (self::$standardtolegacyfields as $from => $to) {
            $selectwhere = str_replace($from, $to, $selectwhere);
            if (!empty($sort)) {
                $sort = str_replace($from, $to, $sort);
            }
            if (isset($params[$from])) {
                $params[$to] = $params[$from];
                unset($params[$from]);
            }
        }

        // Replace crud fields.
        $selectwhere = preg_replace_callback("/(crud).*?(<>|=|!=).*?'(.*?)'/s", 'self::replace_crud', $selectwhere);

        return array($selectwhere, $params, $sort);
    }
protected static function replace_sql_legacy ( $ selectwhere , array $ params , $ sort = '' ) { // Following mapping is done to make can_delete_course() compatible with legacy store. if ( $ selectwhere == "userid = :userid AND courseid = :courseid AND eventname = :eventname AND timecreated > :since" and empty ( $ sort ) ) { $ replace = "module = 'course' AND action = 'new' AND userid = :userid AND url = :url AND time > :since" ; $ params += array ( 'url' => "view.php?id={$params['courseid']}" ) ; return array ( $ replace , $ params , $ sort ) ; } // Replace db field names to make it compatible with legacy log. foreach ( self :: $ standardtolegacyfields as $ from => $ to ) { $ selectwhere = str_replace ( $ from , $ to , $ selectwhere ) ; if ( ! empty ( $ sort ) ) { $ sort = str_replace ( $ from , $ to , $ sort ) ; } if ( isset ( $ params [ $ from ] ) ) { $ params [ $ to ] = $ params [ $ from ] ; unset ( $ params [ $ from ] ) ; } } // Replace crud fields. $ selectwhere = preg_replace_callback ( "/(crud).*?(<>|=|!=).*?'(.*?)'/s" , 'self::replace_crud' , $ selectwhere ) ; return array ( $ selectwhere , $ params , $ sort ) ; }
This method contains mapping required for Moodle core to make legacy store compatible with other sql_reader based
queries.

@param string $selectwhere Select statment
@param array $params params for the sql
@param string $sort sort fields

@return array returns an array containing the sql predicate, an array of params and sorting parameter.
This method contains mapping required for Moodle core to make legacy store compatible with other sql_reader based queries .