data/Relationships/One2MBeanRelationship.php

Show: inherited
Table of Contents

\One2MBeanRelationship

Package: SugarCRM

Represents a one to many relationship that is table based.

It contains at least two links. Each link represents a connection from one record to the records linked in this relationship. Links have a context(focus) bean while relationships do not.

Parent(s)
\One2MRelationship < \M2MRelationship < \SugarRelationship
Children
\One2OneBeanRelationship
Api
 

Properties

Propertyprotected  $beansToResave= 'array()'
Default valuearray()Details
Type
n/a
Inherited_from
\SugarRelationship::$$beansToResave  
Inherited_from
\M2MRelationship::$$beansToResave  
Inherited_from
\One2MRelationship::$$beansToResave  
Propertyprotected  $def= ''
Details
Type
n/a
Inherited_from
\SugarRelationship::$$def  
Inherited_from
\M2MRelationship::$$def  
Inherited_from
\One2MRelationship::$$def  
Propertyprotected  $lhsLink= ''
Details
Type
n/a
Inherited_from
\SugarRelationship::$$lhsLink  
Inherited_from
\M2MRelationship::$$lhsLink  
Inherited_from
\One2MRelationship::$$lhsLink  
Propertyprotected  $rhsLink= ''
Details
Type
n/a
Inherited_from
\SugarRelationship::$$rhsLink  
Inherited_from
\M2MRelationship::$$rhsLink  
Inherited_from
\One2MRelationship::$$rhsLink  
Propertypublic  $type= '"one-to-many"'
Default value"one-to-many"Details
Type
n/a

Methods

methodpublic__construct(  $def ) : void

Parameters
Name Type Description
$def
methodpublic__get(  $name ) : void
Parameters
Name Type Description
$name
methodpublicadd( \$lhs $lhs, \$rhs $rhs, \$additionalFields $additionalFields = array() ) : boolean

Parameters
Name Type Description
$lhs \$lhs

SugarBean left side bean to add to the relationship.

$rhs \$rhs

SugarBean right side bean to add to the relationship.

$additionalFields \$additionalFields

key=>value pairs of fields to save on the relationship

Returns
Type Description
boolean true if successful
methodprotectedaddRow( array $row ) : bool | void
Parameters
Name Type Description
$row array

values to be inserted into the relationship

Returns
Type Description
bool | void null if new row was inserted and true if an exesting row was updated
methodprotectedaddSelfReferencing(  $lhs,  $rhs, array $additionalFields = array() ) : void
inherited

Just overriding the function from M2M to prevent it from occuring

Inherited from: \One2MRelationship::addSelfReferencing()

The logic for dealing with adding self-referencing one-to-many relations is in the add() method

Parameters
Name Type Description
$lhs
$rhs
$additionalFields array
methodpublicaddToResaveList( \SugarBean $bean ) : void
staticinherited

Adds a realted Bean to the list to be resaved along with the current bean.

Inherited from: \SugarRelationship::addToResaveList()\M2MRelationship::addToResaveList()\One2MRelationship::addToResaveList()
Parameters
Name Type Description
$bean \SugarBean
Details
Static
 
methodprotectedcallAfterAdd( \SugarBean $focus, \SugarBean $related, string $link_name = "" ) : void
inherited

Call the after add logic hook for a given link

Inherited from: \SugarRelationship::callAfterAdd()\M2MRelationship::callAfterAdd()\One2MRelationship::callAfterAdd()
Parameters
Name Type Description
$focus \SugarBean

base bean the hooks is triggered from

$related \SugarBean

bean being added/removed/updated from relationship

$link_name string

name of link being triggerd

methodprotectedcallAfterDelete( \SugarBean $focus, \SugarBean $related, string $link_name = "" ) : void
Parameters
Name Type Description
$focus \SugarBean
$related \SugarBean
$link_name string
methodprotectedcallBeforeAdd( \SugarBean $focus, \SugarBean $related, string $link_name = "" ) : void
inherited

Call the before add logic hook for a given link

Inherited from: \SugarRelationship::callBeforeAdd()\M2MRelationship::callBeforeAdd()\One2MRelationship::callBeforeAdd()
Parameters
Name Type Description
$focus \SugarBean

base bean the hooks is triggered from

$related \SugarBean

bean being added/removed/updated from relationship

$link_name string

name of link being triggerd

methodprotectedcallBeforeDelete( \SugarBean $focus, \SugarBean $related, string $link_name = "" ) : void
Parameters
Name Type Description
$focus \SugarBean
$related \SugarBean
$link_name string
methodprotectedcheckExisting(  $row ) : array | bool
inherited

Checks for an existing row who's keys match the one passed in.

Inherited from: \SugarRelationship::checkExisting()\M2MRelationship::checkExisting()\One2MRelationship::checkExisting()
Parameters
Name Type Description
$row
Returns
Type Description
array | bool returns false if now row is found, otherwise the row is returned
methodprotectedgetAlternateKeyFields( ) : Array
Returns
Type Description
Array - set of fields that uniquely identify an entry in this relationship
methodprotectedgetCustomLogicArguments( \SugarBean $focus, \SugarBean $related, string $link_name ) : array
Parameters
Name Type Description
$focus \SugarBean

base bean the hooks is triggered from

$related \SugarBean

bean being added/removed/updated from relationship

$link_name string

name of link being triggerd

Returns
Type Description
array base arguments to pass to relationship logic hooks
methodpublicgetFields( ) : array
Returns
Type Description
array names of fields stored on the relationship
methodpublicgetJoin( \Link2 $link,  $params = array(),  $return_array = false ) : string | array

Parameters
Name Type Description
$link \Link2
$params
$return_array
Returns
Type Description
string | array the query to join against the related modules table for the given link.
methodpublicgetLHSLink( ) : String
Returns
Type Description
String left link in relationship.
methodpublicgetLHSModule( ) : string
Returns
Type Description
string name of left hand side module.
methodpublicgetLinkedDefForModuleByRelationship(  $module ) : array | bool
inherited

Find the link entry for a particular relationship and module.

Inherited from: \M2MRelationship::getLinkedDefForModuleByRelationship()\One2MRelationship::getLinkedDefForModuleByRelationship()
Parameters
Name Type Description
$module
Returns
Type Description
array | bool
methodprotectedgetMostAppropriateLinkedDefinition(  $links ) : bool
inherited

Find the most 'appropriate' link entry for a relationship/module in which there are multiple link entries with the same relationship name.

Inherited from: \M2MRelationship::getMostAppropriateLinkedDefinition()\One2MRelationship::getMostAppropriateLinkedDefinition()
Parameters
Name Type Description
$links
Returns
Type Description
bool
methodprotectedgetOptionalWhereClause( \$optional_array $optional_array ) : string
Parameters
Name Type Description
$optional_array \$optional_array

clause to add to the where query when populating this relationship. It should be in the

Returns
Type Description
string
methodpublicgetQuery( \$link $link,  $params = array() ) : string | array

Gets the query to load a link.

This is currently public, but should prob be made protected later. See Link2->getQuery

Parameters
Name Type Description
$link \$link

Link Object to get query for.

$params
Returns
Type Description
string | array query used to load this relationship
methodpublicgetRHSLink( ) : String
Returns
Type Description
String right link in relationship.
methodpublicgetRHSModule( ) : string
Returns
Type Description
string name of right hand side module.
methodpublicgetRelationshipTable( ) : string

Returns
Type Description
string name of the table for this relationship
methodprotectedgetRoleFilterForJoin( ) : void
methodprotectedgetRoleWhere( string $table = "",  $ignore_role_filter = false ) : string
inherited

Gets the relationship role column check for the where clause

Inherited from: \SugarRelationship::getRoleWhere()\M2MRelationship::getRoleWhere()\One2MRelationship::getRoleWhere()
Parameters
Name Type Description
$table string
$ignore_role_filter
Returns
Type Description
string
methodprotectedgetRowToInsert(  $lhs,  $rhs,  $additionalFields = array() ) : void
Parameters
Name Type Description
$lhs
$rhs
$additionalFields
methodpublicgetSubpanelQuery(  $link, array $params = array(), bool $return_array = false ) : String | Array

Similar to getQuery or Get join, except this time we are starting from the related table and searching for items with id's matching the $link->focus->id

Parameters
Name Type Description
$link
$params array
$return_array bool
Returns
Type Description
String | Array
methodpublicisParentRelationship( ) : bool
Returns
Type Description
bool true if the relationship is a flex / parent relationship
methodprotectedlinkIsLHS(  $link ) : void
inherited

Inherited from: \One2MRelationship::linkIsLHS()
Parameters
Name Type Description
$link
methodpublicload( \$link $link,  $params = array() ) : void

Parameters
Name Type Description
$link \$link

Link2 loads the relationship for this link.

$params
methodpublicrelationship_exists( \SugarBean $lhs, \SugarBean $rhs ) : boolean

Check to see if the relationship already exist.

If it does return true otherwise return false

Parameters
Name Type Description
$lhs \SugarBean

Left hand side of the relationship

$rhs \SugarBean

Right hand side of the relationship

Returns
Type Description
boolean
methodpublicremove( \$lhs $lhs, \$rhs $rhs,  $save = true ) : void

Parameters
Name Type Description
$lhs \$lhs

SugarBean

$rhs \$rhs

SugarBean

$save
methodpublicremoveAll( \$link $link ) : void
Parameters
Name Type Description
$link \$link

Link2 removes all the beans associated with this link from the relationship

methodpublicremoveById( \$rowID $rowID ) : void
Parameters
Name Type Description
$rowID \$rowID

id of SugarBean to remove from the relationship

methodprotectedremoveRow( \$where $where ) : bool | resource
inherited

Removes one or more rows from the relationship table

Inherited from: \SugarRelationship::removeRow()\M2MRelationship::removeRow()\One2MRelationship::removeRow()
Parameters
Name Type Description
$where \$where

array of field=>value pairs to match

Returns
Type Description
bool | resource
methodprotectedremoveSelfReferencing(  $lhs,  $rhs, array $additionalFields = array() ) : void
inherited

Just overriding the function from M2M to prevent it from occuring

Inherited from: \One2MRelationship::removeSelfReferencing()
Parameters
Name Type Description
$lhs
$rhs
$additionalFields array
methodpublicresaveRelatedBeans( ) : void
Details
Static
 
methodprotectedupdateFields(  $lhs,  $rhs,  $additionalFields ) : void

Parameters
Name Type Description
$lhs
$rhs
$additionalFields
methodprotectedupdateLinks(  $lhs,  $lhsLinkName,  $rhs,  $rhsLinkName ) : void

Parameters
Name Type Description
$lhs
$lhsLinkName
$rhs
$rhsLinkName
methodprotectedupdateRow( \$id $id, \$values $values ) : resource
Parameters
Name Type Description
$id \$id

id of row to update

$values \$values

values to insert into row

Returns
Type Description
resource result of update satatement
Documentation was generated by DocBlox 0.18.1.