Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

An object that contains sql join fragments.

Copyright: 2016 The Open University
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 92 lines (3 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

sql_join:: (1 method):
  __construct()


Class: sql_join  - X-Ref

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

__construct($joins = '', $wheres = '', $params = array()   X-Ref
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);

param: string $joins The join sql fragment.
param: string $wheres The where sql fragment.
param: array $params Any parameter values.
param: bool $cannotmatchanyrows If true, this join is guaranteed to match no rows. See comment on the field above.