Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 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.

return: \core_search\document[] Results or false if no 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.

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

This does not commit to the search engine.

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

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

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

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

return: void
param: string $areaid

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.

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

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

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

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

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