Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
core\dml\table Class Reference

Helpers and methods relating to DML tables. More...

Public Member Functions

 __construct (string $tablename, string $tablealias, string $fieldprefix)
 Constructor for the table class. More...
 
 extract_from_result (stdClass $result)
 Extract fields from the specified result. More...
 
 get_field_select ()
 Get the SELECT SQL to select a set of columns for this table. More...
 
 get_from_sql ()
 Get the from TABLE ALIAS part of the FROM/JOIN string. More...
 

Protected Member Functions

 get_fieldlist ()
 Get the list of fields in a table for use in preloading fields. More...
 

Protected Attributes

string $fieldprefix
 Prefix to place before each field.
 
array $fields
 List of fields.
 
string $tablealias
 Table alias.
 
string $tablename
 Name of the table that this class represents.
 

Detailed Description

Helpers and methods relating to DML tables.

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

Constructor & Destructor Documentation

◆ __construct()

core\dml\table::__construct ( string  $tablename,
string  $tablealias,
string  $fieldprefix 
)

Constructor for the table class.

Parameters
string$tablenameThe name of the table that this instance represents.
string$tablealiasThe alias to use when selecting the table
string$fieldprefixThe prefix to use when selecting fields.

Member Function Documentation

◆ extract_from_result()

core\dml\table::extract_from_result ( stdClass  $result)

Extract fields from the specified result.

The fields are removed from the original object.

This function is intended to be used in combination with get_field_select().

Parameters
stdClass$resultThe result retrieved from the database with fields to be extracted
Return values
stdClassThe extracted result

◆ get_field_select()

core\dml\table::get_field_select ( )

Get the SELECT SQL to select a set of columns for this table.

This function is intended to be used in combination with extract_from_result().

Return values
stringThe SQL to use in the SELECT

◆ get_fieldlist()

core\dml\table::get_fieldlist ( )
protected

Get the list of fields in a table for use in preloading fields.

Return values
arrayThe list of columns in a table. The array key is the column name with an applied prefix.

◆ get_from_sql()

core\dml\table::get_from_sql ( )

Get the from TABLE ALIAS part of the FROM/JOIN string.

Return values
string

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