Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
mod_forum\local\vaults\db_table_vault Class Reference

Abstract class for loading records from the DB. More...

Inheritance diagram for mod_forum\local\vaults\db_table_vault:
mod_forum\local\vaults\author mod_forum\local\vaults\discussion mod_forum\local\vaults\discussion_list mod_forum\local\vaults\forum mod_forum\local\vaults\post mod_forum\local\vaults\post_read_receipt_collection

Public Member Functions

 __construct (moodle_database $db, entity_factory $entityfactory, $legacyfactory)
 Constructor.
 
 get_from_id (int $id)
 Get the entity for the given id.
 
 get_from_ids (array $ids)
 Get the list of entities for the given ids.
 

Protected Member Functions

 from_db_records (array $results)
 Convert the DB records into entities.
 
 generate_get_records_sql (string $wheresql=null, string $sortsql=null, ?int $userid=null)
 Build the SQL to be used in get_records_sql.
 
 get_db ()
 Get the moodle database.
 
 get_entity_factory ()
 Get the entity factory.
 
 get_legacy_factory ()
 Get the legacy factory.
 
 get_preprocessors ()
 Get the list of preprocessors to run on the DB record results.
 
 get_table_alias ()
 Get the table alias.
 
 transform_db_records_to_entities (array $records)
 Execute the defined preprocessors on the DB record results and then convert them into entities.
 

Detailed Description

Abstract class for loading records from the DB.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

mod_forum\local\vaults\db_table_vault::__construct ( moodle_database $db,
entity_factory $entityfactory,
$legacyfactory )

Constructor.

Parameters
moodle_database$dbA moodle database
entity_factory$entityfactoryEntity factory
object$legacyfactoryLegacy factory

Member Function Documentation

◆ from_db_records()

mod_forum\local\vaults\db_table_vault::from_db_records ( array $results)
abstractprotected

Convert the DB records into entities.

The list of records will have been passed through any preprocessors that may be defined before being given to this function.

Each result will from the list will be an associative array where the key is set to the identifier given to the preprocessor and the result is the value generated by the preprocessor.

All results will have a 'record' key who's value is the original DB record.

Parameters
array$resultsThe DB records

Reimplemented in mod_forum\local\vaults\author, mod_forum\local\vaults\discussion, mod_forum\local\vaults\discussion_list, mod_forum\local\vaults\forum, mod_forum\local\vaults\post, and mod_forum\local\vaults\post_read_receipt_collection.

◆ generate_get_records_sql()

mod_forum\local\vaults\db_table_vault::generate_get_records_sql ( string $wheresql = null,
string $sortsql = null,
?int $userid = null )
abstractprotected

Build the SQL to be used in get_records_sql.

Parameters
string | null$wheresqlWhere conditions for the SQL
string | null$sortsqlOrder by conditions for the SQL
object | null$userThe user object
Return values
string

Reimplemented in mod_forum\local\vaults\author, mod_forum\local\vaults\discussion, mod_forum\local\vaults\forum, mod_forum\local\vaults\post, and mod_forum\local\vaults\post_read_receipt_collection.

◆ get_db()

mod_forum\local\vaults\db_table_vault::get_db ( )
protected

Get the moodle database.

Return values
moodle_database

◆ get_entity_factory()

mod_forum\local\vaults\db_table_vault::get_entity_factory ( )
protected

Get the entity factory.

Return values
entity_factory

◆ get_from_id()

mod_forum\local\vaults\db_table_vault::get_from_id ( int $id)

Get the entity for the given id.

Parameters
int$idIdentifier for the entity
Return values
object|null

◆ get_from_ids()

mod_forum\local\vaults\db_table_vault::get_from_ids ( array $ids)

Get the list of entities for the given ids.

Parameters
int[]$idsIdentifiers
Return values
array

◆ get_legacy_factory()

mod_forum\local\vaults\db_table_vault::get_legacy_factory ( )
protected

Get the legacy factory.

Return values
object

◆ get_preprocessors()

mod_forum\local\vaults\db_table_vault::get_preprocessors ( )
protected

Get the list of preprocessors to run on the DB record results.

The preprocessors should be defined using an associative array. The key used to identify the preprocessor in this list will be used to identify the value of that preprocessor in the list of results when passed to the from_db_records function.

Return values
array

Reimplemented in mod_forum\local\vaults\discussion_list, and mod_forum\local\vaults\forum.

◆ get_table_alias()

mod_forum\local\vaults\db_table_vault::get_table_alias ( )
abstractprotected

◆ transform_db_records_to_entities()

mod_forum\local\vaults\db_table_vault::transform_db_records_to_entities ( array $records)
protected

Execute the defined preprocessors on the DB record results and then convert them into entities.

Parameters
stdClass[]$recordsList of DB results
Return values
array

The documentation for this class was generated from the following file: