Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
core\dml\sql_join Class Reference

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.
 

Detailed Description

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);

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

Constructor & Destructor Documentation

◆ __construct()

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);

Parameters
string$joinsThe join sql fragment.
string$wheresThe where sql fragment.
array$paramsAny parameter values.
bool$cannotmatchanyrowsIf true, this join is guaranteed to match no rows. See comment on the field above.

Member Data Documentation

◆ $cannotmatchanyrows

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.

Since
Moodle 3.9/3.8.3/3.7.6.

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