Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.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.