data/Relationships/M2MRelationship.php
\M2MRelationship
Represents a many 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)
- \SugarRelationship
- Children
- \One2MRelationship
- \One2OneRelationship
- \EmailAddressRelationship
- Api
Properties

$beansToResave= 'array()'
array()Details- Type
- n/a
- Inherited_from
- \SugarRelationship::$$beansToResave

$def= ''
- Type
- n/a
- Inherited_from
- \SugarRelationship::$$def

$ignore_role_filter= 'false'
falseDetails- Type
- n/a
- Inherited_from
- \SugarRelationship::$$ignore_role_filter

$lhsLink= ''
- Type
- n/a
- Inherited_from
- \SugarRelationship::$$lhsLink

$rhsLink= ''
- Type
- n/a
- Inherited_from
- \SugarRelationship::$$rhsLink

$self_referencing= 'false'
falseDetails- Type
- n/a
- Inherited_from
- \SugarRelationship::$$self_referencing
Methods

__get(
$name
)
:
void| Name | Type | Description |
|---|---|---|
| $name |

add(
\$lhs $lhs, \$rhs $rhs, \$additionalFields $additionalFields
=
array()
)
:
boolean| 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 |
| Type | Description |
|---|---|
| boolean | true if successful |

addRow(
array $row
)
:
bool | void| Name | Type | Description |
|---|---|---|
| $row | array | values to be inserted into the relationship |
| Type | Description |
|---|---|
| bool | void | null if new row was inserted and true if an exesting row was updated |

addSelfReferencing(
$lhs, $rhs, array $additionalFields
=
array()
)
:
voidAdds the reversed version of this relationship to the table so that it can be accessed from either side equally
| Name | Type | Description |
|---|---|---|
| $lhs | ||
| $rhs | ||
| $additionalFields | array |

addToResaveList(
\SugarBean $bean
)
:
voidAdds a realted Bean to the list to be resaved along with the current bean.
Inherited from: \SugarRelationship::addToResaveList()| Name | Type | Description |
|---|---|---|
| $bean | \SugarBean |
- Static

callAfterAdd(
\SugarBean $focus, \SugarBean $related, string $link_name
=
""
)
:
voidCall the after add logic hook for a given link
Inherited from: \SugarRelationship::callAfterAdd()| 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 |

callAfterDelete(
\SugarBean $focus, \SugarBean $related, string $link_name
=
""
)
:
void| Name | Type | Description |
|---|---|---|
| $focus | \SugarBean | |
| $related | \SugarBean | |
| $link_name | string |

callBeforeAdd(
\SugarBean $focus, \SugarBean $related, string $link_name
=
""
)
:
voidCall the before add logic hook for a given link
Inherited from: \SugarRelationship::callBeforeAdd()| 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 |

callBeforeDelete(
\SugarBean $focus, \SugarBean $related, string $link_name
=
""
)
:
void| Name | Type | Description |
|---|---|---|
| $focus | \SugarBean | |
| $related | \SugarBean | |
| $link_name | string |

checkExisting(
$row
)
:
array | boolChecks for an existing row who's keys match the one passed in.
Inherited from: \SugarRelationship::checkExisting()| Name | Type | Description |
|---|---|---|
| $row |
| Type | Description |
|---|---|
| array | bool | returns false if now row is found, otherwise the row is returned |

getAlternateKeyFields(
)
:
Array| Type | Description |
|---|---|
| Array | - set of fields that uniquely identify an entry in this relationship |

getCustomLogicArguments(
\SugarBean $focus, \SugarBean $related, string $link_name
)
:
array| 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 |
| Type | Description |
|---|---|
| array | base arguments to pass to relationship logic hooks |

getJoin(
\Link2 $link, $params
=
array(), $return_array
=
false
)
:
string | array| Name | Type | Description |
|---|---|---|
| $link | \Link2 | |
| $params | ||
| $return_array |
| Type | Description |
|---|---|
| string | array | the query to join against the related modules table for the given link. |

getLHSLink(
)
:
String| Type | Description |
|---|---|
| String | left link in relationship. |

getLHSModule(
)
:
string| Type | Description |
|---|---|
| string | name of left hand side module. |

getLinkedDefForModuleByRelationship(
$module
)
:
array | boolFind the link entry for a particular relationship and module.
| Name | Type | Description |
|---|---|---|
| $module |
| Type | Description |
|---|---|
| array | bool |

getMostAppropriateLinkedDefinition(
$links
)
:
boolFind the most 'appropriate' link entry for a relationship/module in which there are multiple link entries with the same relationship name.
| Name | Type | Description |
|---|---|---|
| $links |
| Type | Description |
|---|---|
| bool |

getOptionalWhereClause(
\$optional_array $optional_array
)
:
string| Name | Type | Description |
|---|---|---|
| $optional_array | \$optional_array | clause to add to the where query when populating this relationship. It should be in the |
| Type | Description |
|---|---|
| string |

getQuery(
\$link $link, $params
=
array()
)
:
string | arrayGets the query to load a link.
This is currently public, but should prob be made protected later. See Link2->getQuery
| Name | Type | Description |
|---|---|---|
| $link | \$link | Link Object to get query for. |
| $params |
| Type | Description |
|---|---|
| string | array | query used to load this relationship |

getRHSLink(
)
:
String| Type | Description |
|---|---|
| String | right link in relationship. |

getRHSModule(
)
:
string| Type | Description |
|---|---|
| string | name of right hand side module. |

getRelationshipTable(
)
:
string| Type | Description |
|---|---|
| string | name of the table for this relationship |

getRoleWhere(
string $table
=
"", $ignore_role_filter
=
false
)
:
stringGets the relationship role column check for the where clause
Inherited from: \SugarRelationship::getRoleWhere()| Name | Type | Description |
|---|---|---|
| $table | string | |
| $ignore_role_filter |
| Type | Description |
|---|---|
| string |

getRowToInsert(
$lhs, $rhs, $additionalFields
=
array()
)
:
void| Name | Type | Description |
|---|---|---|
| $lhs | ||
| $rhs | ||
| $additionalFields |

getSubpanelQuery(
$link, array $params
=
array(), bool $return_array
=
false
)
:
String | ArraySimilar 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
| Name | Type | Description |
|---|---|---|
| $link | ||
| $params | array | |
| $return_array | bool |
| Type | Description |
|---|---|
| String | Array |

isParentRelationship(
)
:
bool| Type | Description |
|---|---|
| bool | true if the relationship is a flex / parent relationship |

load(
\$link $link, $params
=
array()
)
:
void| Name | Type | Description |
|---|---|---|
| $link | \$link | Link2 loads the relationship for this link. |
| $params |

relationship_exists(
$lhs, $rhs
)
:
bool| Name | Type | Description |
|---|---|---|
| $lhs | ||
| $rhs |
| Type | Description |
|---|---|
| bool |

remove(
\$lhs $lhs, \$rhs $rhs
)
:
void| Name | Type | Description |
|---|---|---|
| $lhs | \$lhs | SugarBean |
| $rhs | \$rhs | SugarBean |

removeAll(
\$link $link
)
:
void| Name | Type | Description |
|---|---|---|
| $link | \$link | Link2 removes all the beans associated with this link from the relationship |

removeById(
\$rowID $rowID
)
:
void| Name | Type | Description |
|---|---|---|
| $rowID | \$rowID | id of SugarBean to remove from the relationship |

removeRow(
\$where $where
)
:
bool | resourceRemoves one or more rows from the relationship table
Inherited from: \SugarRelationship::removeRow()| Name | Type | Description |
|---|---|---|
| $where | \$where | array of field=>value pairs to match |
| Type | Description |
|---|---|
| bool | resource |

removeSelfReferencing(
$lhs, $rhs, array $additionalFields
=
array()
)
:
voidRemoves the reversed version of this relationship
| Name | Type | Description |
|---|---|---|
| $lhs | ||
| $rhs | ||
| $additionalFields | array |

updateRow(
\$id $id, \$values $values
)
:
resource| Name | Type | Description |
|---|---|---|
| $id | \$id | id of row to update |
| $values | \$values | values to insert into row |
| Type | Description |
|---|---|
| resource | result of update satatement |