protected function get_searchsql() {
        global $DB;

        $ctxselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
        $ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)";
        $params = array(
            'contextlevel' => CONTEXT_COURSE,
            'fullnamesearch' => '%'.$this->get_search().'%',
            'shortnamesearch' => '%'.$this->get_search().'%'
        );

        $select     = " SELECT c.id, c.fullname, c.shortname, c.visible, c.sortorder ";
        $from       = " FROM {course} c ";
        $where      = " WHERE (".$DB->sql_like('c.fullname', ':fullnamesearch', false)." OR ".
            $DB->sql_like('c.shortname', ':shortnamesearch', false).")";
        $orderby    = " ORDER BY c.sortorder";

        if ($this->currentcourseid !== null && !$this->includecurrentcourse) {
            $where .= " AND c.id <> :currentcourseid";
            $params['currentcourseid'] = $this->currentcourseid;
        }

        return array($select.$ctxselect.$from.$ctxjoin.$where.$orderby, $params);
    }
protected function get_searchsql() {
        global $DB;

        $ctxselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
        $ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)";
        $params = array(
            'contextlevel' => CONTEXT_COURSE,
            'fullnamesearch' => '%'.$this->get_search().'%',
            'shortnamesearch' => '%'.$this->get_search().'%'
        );

        $select     = " SELECT c.id, c.fullname, c.shortname, c.visible, c.sortorder ";
        $from       = " FROM {course} c ";
        $where      = " WHERE (".$DB->sql_like('c.fullname', ':fullnamesearch', false)." OR ".
            $DB->sql_like('c.shortname', ':shortnamesearch', false).")";
        $orderby    = " ORDER BY c.sortorder";

        if ($this->currentcourseid !== null && !$this->includecurrentcourse) {
            $where .= " AND c.id <> :currentcourseid";
            $params['currentcourseid'] = $this->currentcourseid;
        }

        return array($select.$ctxselect.$from.$ctxjoin.$where.$orderby, $params);
    }
protected function get_searchsql ( ) { global $ DB ; $ ctxselect = ', ' . context_helper :: get_preload_record_columns_sql ( 'ctx' ) ; $ ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)" ; $ params = array ( 'contextlevel' => CONTEXT_COURSE , 'fullnamesearch' => '%' . $ this -> get_search ( ) . '%' , 'shortnamesearch' => '%' . $ this -> get_search ( ) . '%' ) ; $ select = " SELECT c.id, c.fullname, c.shortname, c.visible, c.sortorder " ; $ from = " FROM {course} c " ; $ where = " WHERE (" . $ DB -> sql_like ( 'c.fullname' , ':fullnamesearch' , false ) . " OR " . $ DB -> sql_like ( 'c.shortname' , ':shortnamesearch' , false ) . ")" ; $ orderby = " ORDER BY c.sortorder" ; if ( $ this -> currentcourseid !== null && ! $ this -> includecurrentcourse ) { $ where .= " AND c.id <> :currentcourseid" ; $ params [ 'currentcourseid' ] = $ this -> currentcourseid ; } return array ( $ select . $ ctxselect . $ from . $ ctxjoin . $ where . $ orderby , $ params ) ; }
Get the search SQL.
@global moodle_database $DB
@return array
Get the search SQL .