Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
|
An object that contains sql join fragments. More...
Public Member Functions | |
__construct ($joins='', $wheres='', $params=array(), $cannotmatchanyrows=false) | |
Create an object that contains sql join fragments. | |
Public Attributes | |
bool | $cannotmatchanyrows |
if true this join is guaranteed to never match any rows. | |
string | $joins |
joins. | |
array | $params |
params. | |
string | $wheres |
wheres. | |
An object that contains sql join fragments.
An example of how to use this class in a simple query, where you have got a join that is a join to the user table:
$users = $DB->get_records_sql("SELECT u.* FROM {user} u {$sqljoin->joins} WHERE {$sqljoin->wheres}", $sqljoin->params);
core\dml\sql_join::__construct | ( | $joins = '', | |
$wheres = '', | |||
$params = array(), | |||
$cannotmatchanyrows = false ) |
Create an object that contains sql join fragments.
Note, even if you set $cannotmatchanyrows to true, it is important to also set the other fields because the calling code is not required to check it. For example new core\dml\sql_join('', '1 = 2', [], true);
string | $joins | The join sql fragment. |
string | $wheres | The where sql fragment. |
array | $params | Any parameter values. |
bool | $cannotmatchanyrows | If true, this join is guaranteed to match no rows. See comment on the field above. |
bool core\dml\sql_join::$cannotmatchanyrows |
if true this join is guaranteed to never match any rows.
In this case, the calling code may be able to completely skip doing the database query.