Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 403]

Simple moodle database engine.

Copyright: 2016 David Monllao {@link http://www.davidmonllao.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 395 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: engine  - X-Ref

Simple moodle database engine.

execute_query($filters, $usercontexts, $limit = 0)   X-Ref
Prepares a SQL query, applies filters and executes it returning its results.

param: stdClass     $filters Containing query and filters.
param: array        $usercontexts Contexts where the user has access. True if the user can access all contexts.
param: int          $limit The maximum number of results to return.
return: \core_search\document[] Results or false if no results

add_document($document, $fileindexing = false)   X-Ref
Adds a document to the search engine.

This does not commit to the search engine.

param: \core_search\document $document
param: bool $fileindexing True if file indexing is to be used
return: bool False if the file was skipped or failed, true on success

delete_by_id($id)   X-Ref
Deletes the specified document.

param: string $id The document id to delete
return: void

delete($areaid = null)   X-Ref
Delete all area's documents.

param: string $areaid
return: void

is_server_ready()   X-Ref
Checks that the required table was installed.

return: true|string Returns true if all good or an error string.

is_installed()   X-Ref
It is always installed.

return: true

get_query_total_count()   X-Ref
Returns the total results.

Including skipped results.

return: int

get_simple_query($q)   X-Ref
Returns the default query for db engines.

param: string $q The query string
return: array SQL string and params list

delete_index_for_context(int $oldcontextid)   X-Ref
Simpledb supports deleting the index for a context.

param: int $oldcontextid Context that has been deleted
return: bool True to indicate that any data was actually deleted

delete_index_for_course(int $oldcourseid)   X-Ref
Simpledb supports deleting the index for a course.

param: int $oldcourseid
return: bool True to indicate that any data was actually deleted