CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.1 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.1
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
    • Event
    • Filesystem
    • Form
    • I18n
      • Formatter
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
      • Http
        • Adapter
        • Auth
        • FormData
      • Session
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • BelongsTo
  • BelongsToMany
  • HasMany
  • HasOne

Traits

  • DependentDeleteTrait
  • ExternalAssociationTrait
  • SelectableAssociationTrait

Trait ExternalAssociationTrait

Represents a type of association that that needs to be recovered by performing an extra query.

Cake\ORM\Association\ExternalAssociationTrait uses Cake\ORM\Association\SelectableAssociationTrait

Direct Users

  • Cake\ORM\Association\BelongsToMany
  • Cake\ORM\Association\HasMany
Namespace: Cake\ORM\Association
Location: ORM/Association/ExternalAssociationTrait.php

Properties summary

  • $_sort protected
    mixed
    Order in which target records should be returned

Method Summary

  • _buildResultMap() protected
  • _defaultOptions() protected
    Returns the default options to use for the eagerLoader
  • _options() protected
    Parse extra options passed in the constructor.
  • canBeJoined() public
    Whether this association can be expressed directly in a query join
  • defaultRowValue() public
  • foreignKey() public

    Sets the name of the field representing the foreign key to the source table. If no parameters are passed current field is returned

  • sort() public

    Sets the sort order in which target records should be returned. If no arguments are passed the currently configured value is returned

Method Detail

_buildResultMap() protected ¶

_buildResultMap( $fetchQuery , $options )

_defaultOptions() protected ¶

_defaultOptions( )

Returns the default options to use for the eagerLoader

Returns
array

_options() protected ¶

_options( array $opts )

Parse extra options passed in the constructor.

Parameters
array $opts
original list of options passed in constructor

canBeJoined() public ¶

canBeJoined( array $options = [] )

Whether this association can be expressed directly in a query join

Parameters
array $options optional []
custom options key that could alter the return value
Returns
boolean

if the 'matching' key in $option is true then this function will return true, false otherwise


defaultRowValue() public ¶

defaultRowValue( $row , $joined )

foreignKey() public ¶

foreignKey( string|null $key = null )

Sets the name of the field representing the foreign key to the source table. If no parameters are passed current field is returned

Parameters
string|null $key optional null
the key to be used to link both tables together
Returns
string

sort() public ¶

sort( mixed $sort = null )

Sets the sort order in which target records should be returned. If no arguments are passed the currently configured value is returned

Parameters
mixed $sort optional null
A find() compatible order clause
Returns
mixed

Methods used from Cake\ORM\Association\SelectableAssociationTrait

_addFilteringCondition() protected ¶

_addFilteringCondition( Cake\ORM\Query $query , string|array $key , mixed $filter )

Appends any conditions required to load the relevant set of records in the target table query given a filter key and some filtering values.

Parameters
Cake\ORM\Query $query
Target table's query
string|array $key
the fields that should be used for filtering
mixed $filter
the value that should be used to match for $key
Returns
Cake\ORM\Query

_addFilteringJoin() public ¶

_addFilteringJoin( Cake\ORM\Query $query , string $key , Cake\ORM\Query $subquery )

Appends any conditions required to load the relevant set of records in the target table query given a filter key and some filtering values when the filtering needs to be done using a subquery.

Parameters
Cake\ORM\Query $query
Target table's query
string $key
the fields that should be used for filtering
Cake\ORM\Query $subquery
The Subquery to use for filtering
Returns
Cake\ORM\Query

_buildQuery() protected ¶

_buildQuery( array $options )

Auxiliary function to construct a new Query object to return all the records in the target table that are associated to those specified in $options from the source table

Parameters
array $options
options accepted by eagerLoader()
Returns
Cake\ORM\Query
Throws
InvalidArgumentException
When a key is required for associations but not selected.

_buildSubquery() protected ¶

_buildSubquery( Cake\ORM\Query $query )

Builds a query to be used as a condition for filtering records in the target table, it is constructed by cloning the original query that was used to load records in the source table.

Parameters
Cake\ORM\Query $query
the original query used to load source records
Returns
Cake\ORM\Query

_createTupleCondition() protected ¶

_createTupleCondition( Cake\ORM\Query $query , array $keys , mixed $filter , string $operator )

Returns a TupleComparison object that can be used for matching all the fields from $keys with the tuple values in $filter using the provided operator.

Parameters
Cake\ORM\Query $query
Target table's query
array $keys
the fields that should be used for filtering
mixed $filter
the value that should be used to match for $key
string $operator
The operator for comparing the tuples
Returns
Cake\Database\Expression\TupleComparison

_linkField() abstract protected ¶

_linkField( array $options )

Generates a string used as a table field that contains the values upon which the filter should be applied

Parameters
array $options
The options for getting the link field.
Returns
string|array

_multiKeysInjector() protected ¶

_multiKeysInjector( array $resultMap , array $sourceKeys , string $nestKey )

Returns a callable to be used for each row in a query result set for injecting the eager loaded rows when the matching needs to be done with multiple foreign keys

Parameters
array $resultMap
A keyed arrays containing the target table
array $sourceKeys
An array with aliased keys to match
string $nestKey
The key under which results should be nested
Returns
Closure

_resultInjector() protected ¶

_resultInjector( Cake\ORM\Query $fetchQuery , array $resultMap , array $options )

Returns a callable to be used for each row in a query result set for injecting the eager loaded rows

Parameters
Cake\ORM\Query $fetchQuery
the Query used to fetch results
array $resultMap

an array with the foreignKey as keys and the corresponding target table results as value.

array $options
The options passed to the eagerLoader method
Returns
Closure

_subqueryFields() protected ¶

_subqueryFields( Cake\ORM\Query $query )

Calculate the fields that need to participate in a subquery.

Normally this includes the binding key columns. If there is a an ORDER BY, those columns are also included as the fields may be calculated or constant values, that need to be present to ensure the correct association data is loaded.

Parameters
Cake\ORM\Query $query
The query to get fields from.
Returns
array
The list of fields for the subquery.

eagerLoader() public ¶

eagerLoader( array $options )

requiresKeys() public ¶

requiresKeys( array $options = [] )

Returns true if the eager loading process will require a set of the owning table's binding keys in order to use them as a filter in the finder query.

Parameters
array $options optional []
The options containing the strategy to be used.
Returns
boolean
true if a list of keys will be required

Properties detail

$_sort ¶

protected mixed

Order in which target records should be returned

Follow @CakePHP
#IRC
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs