Elgg  Version 6.2
Public Member Functions | Protected Member Functions | List of all members
Elgg\Database\Relationships Class Reference

Relationships repository contains methods for fetching relationships from database or performing calculations on relationship properties. More...

Inheritance diagram for Elgg\Database\Relationships:
Elgg\Database\Repository

Public Member Functions

 calculate ($function, $property, $property_type=null)
 Apply numeric calculation to a column.
Parameters
string$functionCalculation, e.g. max, min, avg
string$propertyProperty name
string$property_typeProperty type
Returns
int|float
More...
 
 count ()
 Count rows.
Returns
int
More...
 
 execute ()
 Apply correct execution method based on calculation, count or other criteria.
Returns
mixed
More...
 
 get ($limit=null, $offset=null, $callback=null)
 Fetch rows.
Parameters
int$limitNumber of rows to fetch
int$offsetIndex of the first row
callable | false$callbackCallback function to run database rows through
Returns
\ElggData[]|false
More...
 
- Public Member Functions inherited from Elgg\Database\Repository
 __construct (array $options=[])
 Constructor. More...
 
 __get ($name)
 {} More...
 
 __set ($name, $value)
 {} More...
 
 __unset ($name)
 {} More...
 
 __isset ($name)
 {} More...
 
 batch ($limit=null, $offset=null, $callback=null)
 Fetch rows as an ElggBatch. More...
 
 filter (\Closure $closure)
 Filter query prior to execution Callback function will receive QueryBuilder as the first argument and table alias as a second Callback function can either mutate the instance of the QueryBuilder or return a composition expression that will be appended to AND where statements. More...
 
 select ($expression)
 Add SELECT. More...
 
 join ($joined_table, $joined_alias=null, $join_column=null, $comparison=null, $values=null, $type=null, $case_sensitive=null)
 Add JOIN clause Join a database table on an $x to $y comparison. More...
 
 groupBy ($expression)
 Add GROUP BY. More...
 
 having ($expression)
 Add HAVING. More...
 
 orderBy ($expression, $direction)
 Add ORDER BY. More...
 
 expandInto (QueryBuilder $qb, $table_alias=null)
 Extend query builder with select, group_by, having and order_by clauses from $options. More...
 

Protected Member Functions

 buildQuery (QueryBuilder $qb)
 Build a database query. More...
 
 buildEntityClause (QueryBuilder $qb)
 Process entity attribute wheres Joins entities table on guid_one|guid_two in relationships table and applies where clauses. More...
 
 buildPairedMetadataClause (QueryBuilder $qb, $clauses, $boolean='AND')
 Process metadata name value pairs Joins the metadata table on guid_one|guid_two in relationships table and applies metadata where clauses. More...
 
 buildPairedAnnotationClause (QueryBuilder $qb, $clauses, $boolean='AND')
 Process annotation name value pairs Joins the annotation table on guid_one|guid_two in relationships table and applies annotation where clauses. More...
 
 buildPairedRelationshipClause (QueryBuilder $qb, $clauses, $boolean='AND')
 Process relationship pairs. More...
 
 getJoinColumn ()
 Return the base column to use in joins. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Elgg\Database\Repository
static with (array $options=[])
 Constructs a new. More...
 
static find (array $options=[])
 Build and execute a new query from an array of legacy options. More...
 
- Protected Attributes inherited from Elgg\Database\Repository
QueryOptions $options
 

Detailed Description

Relationships repository contains methods for fetching relationships from database or performing calculations on relationship properties.

Since
3.2

Definition at line 21 of file Relationships.php.

Member Function Documentation

◆ buildEntityClause()

Elgg\Database\Relationships::buildEntityClause ( QueryBuilder  $qb)
protected

Process entity attribute wheres Joins entities table on guid_one|guid_two in relationships table and applies where clauses.

Parameters
QueryBuilder$qbQuery builder
Returns
\Closure|CompositeExpression|mixed|null|string

Definition at line 213 of file Relationships.php.

◆ buildPairedAnnotationClause()

Elgg\Database\Relationships::buildPairedAnnotationClause ( QueryBuilder  $qb,
  $clauses,
  $boolean = 'AND' 
)
protected

Process annotation name value pairs Joins the annotation table on guid_one|guid_two in relationships table and applies annotation where clauses.

Parameters
QueryBuilder$qbQuery builder
AnnotationWhereClause[]$clausesWhere clauses
string$booleanMerge boolean
Returns
CompositeExpression|string

Definition at line 258 of file Relationships.php.

◆ buildPairedMetadataClause()

Elgg\Database\Relationships::buildPairedMetadataClause ( QueryBuilder  $qb,
  $clauses,
  $boolean = 'AND' 
)
protected

Process metadata name value pairs Joins the metadata table on guid_one|guid_two in relationships table and applies metadata where clauses.

Parameters
QueryBuilder$qbQuery builder
MetadataWhereClause[]$clausesWhere clauses
string$booleanMerge boolean
Returns
CompositeExpression|string

Definition at line 228 of file Relationships.php.

◆ buildPairedRelationshipClause()

Elgg\Database\Relationships::buildPairedRelationshipClause ( QueryBuilder  $qb,
  $clauses,
  $boolean = 'AND' 
)
protected

Process relationship pairs.

Parameters
QueryBuilder$qbQuery builder
RelationshipWhereClause[]$clausesWhere clauses
string$booleanMerge boolean
Returns
CompositeExpression|string

Definition at line 285 of file Relationships.php.

◆ buildQuery()

Elgg\Database\Relationships::buildQuery ( QueryBuilder  $qb)
protected

Build a database query.

Parameters
QueryBuilder$qbQuerybuilder with relationship params
Returns
QueryBuilder

Definition at line 180 of file Relationships.php.

◆ calculate()

Elgg\Database\Relationships::calculate (   $function,
  $property,
  $property_type = null 
)

Apply numeric calculation to a column.

Parameters
string$functionCalculation, e.g. max, min, avg
string$propertyProperty name
string$property_typeProperty type
Returns
int|float

Exceptions
DomainException

Reimplemented from Elgg\Database\Repository.

Definition at line 27 of file Relationships.php.

◆ count()

Elgg\Database\Relationships::count ( )

Count rows.

Returns
int

Reimplemented from Elgg\Database\Repository.

Definition at line 79 of file Relationships.php.

◆ execute()

Elgg\Database\Relationships::execute ( )

Apply correct execution method based on calculation, count or other criteria.

Returns
mixed

Reimplemented from Elgg\Database\Repository.

Definition at line 98 of file Relationships.php.

◆ get()

Elgg\Database\Relationships::get (   $limit = null,
  $offset = null,
  $callback = null 
)

Fetch rows.

Parameters
int$limitNumber of rows to fetch
int$offsetIndex of the first row
callable | false$callbackCallback function to run database rows through
Returns
\ElggData[]|false

Reimplemented from Elgg\Database\Repository.

Definition at line 129 of file Relationships.php.

◆ getJoinColumn()

Elgg\Database\Relationships::getJoinColumn ( )
protected

Return the base column to use in joins.

Returns
string

Definition at line 300 of file Relationships.php.


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