Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Generic temptables object store

Copyright: 2009 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 145 lines (6 kb)
Included or required: 5 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

moodle_temptables:: (8 methods):
  __construct()
  add_temptable()
  delete_temptable()
  get_temptables()
  is_temptable()
  get_correct_name()
  update_stats()
  dispose()


Class: moodle_temptables  - X-Ref

__construct($mdb)   X-Ref
Creates new moodle_temptables instance

param: moodle_database $mdb An instance of moodle_database.

add_temptable($tablename)   X-Ref
Add one temptable to the store

Given one moodle temptable name (without prefix), add it to the store, with the
key being the original moodle name and the value being the real db temptable name
already prefixed

Override and use this *only* if the database requires modification in the table name.

param: string $tablename name without prefix of the table created as temptable

delete_temptable($tablename)   X-Ref
Delete one temptable from the store

param: string $tablename name without prefix of the dropped temptable

get_temptables()   X-Ref
Returns all the tablenames (without prefix) existing in the store

return: array containing all the tablenames in the store (tablename both key and value)

is_temptable($tablename)   X-Ref
Returns if one table, based in the information present in the store, is a temp table

param: string $tablename name without prefix of the table we are asking about
return: bool true if the table is a temp table (based in the store info), false if not

get_correct_name($tablename)   X-Ref
Given one tablename (no prefix), return the name of the corresponding temporary table,
If the table isn't a "registered" temp table, returns null

param: string $tablename name without prefix which corresponding temp tablename needs to know
return: mixed DB name of the temp table or null if it isn't a temp table

update_stats()   X-Ref
Analyze the data in temporary tables to force statistics collection after bulk data loads.
The database class detects all temporary tables and will automatically analyze all created tables

return: void

dispose()   X-Ref
Dispose the temptables stuff, checking for wrong situations, informing and recovering from them