modules/Products/AccountLink.php
Package: Represents a relationship from a single beans perspective.
- Parent(s)
- \Link2
Properties
Methods
__construct(
\$linkName $linkName, \$bean $bean, \$linkDef $linkDef
=
false
)
:
void
Parameters
Name |
Type |
Description |
$linkName |
\$linkName |
String name of a link field in the module's vardefs
|
$bean |
\$bean |
SugarBean focus bean for this link (one half of a relationship)
|
$linkDef |
\$linkDef |
Array Optional vardef for the link in case it can't be found in the passed in bean for the global dictionary
|
_get_link_table_role_field(
\$table_name $table_name
)
:
bool | string
Parameters
Name |
Type |
Description |
$table_name |
\$table_name |
name of relationship table to inspect |
Returns
Type |
Description |
bool | string |
|
add(
array $rel_keys, array $additional_values
=
array()
)
:
boolean | array
inheriteduse this function to create link between 2 objects
1:1 will be treated like 1 to many.
Inherited from:
\Link2::add()
the function also allows for setting of values for additional field in the table being
updated to save the relationship, in case of many-to-many relationships this would be the join table.
Parameters
Name |
Type |
Description |
$rel_keys |
array |
array of ids or SugarBean objects. If you have the bean in memory, pass it in. |
$additional_values |
array |
the values should be passed as key value pairs with column name as the key name and column value as key value. |
Returns
Type |
Description |
boolean | array |
Return true if all relationships were added. Return an array with the failed keys if any of them failed. |
addBean(
\SugarBean $bean
)
:
void
inheritedAdd a bean object to the list of beans currently loaded to this relationship.
Inherited from:
\Link2::addBean()
This for the most part should not need to be called except by the relatipnship implementation classes.
Parameters
delete(
\$id $id, string $related_id
=
''
)
:
boolean
inheritedMarks the relationship delted for this given record pair.
Inherited from:
\Link2::delete()
Parameters
Name |
Type |
Description |
$id |
\$id |
id of the Parent/Focus SugarBean
|
$related_id |
string |
id or SugarBean to unrelate. Pass a SugarBean if you have it. |
Returns
Type |
Description |
boolean |
true if delete was successful or false if it was not |
getBeans(
array $params
=
array()
)
:
array
inheritedUse with caution as if you have a large list of beans in the relationship,
it can cause the app to timeout or run out of memory.
Inherited from:
\Link2::getBeans()
Parameters
Name |
Type |
Description |
$params |
array |
An array that can contain the following parameters:
|
Returns
Type |
Description |
array |
of SugarBeans related through this link. |
getJoin(
\$params $params, bool $return_array
=
false
)
:
\string/array
Parameters
Name |
Type |
Description |
$params |
\$params |
array of parameters. Possible parameters include: 'join_table_link_alias': alias the relationship join table in the query (for M2M relationships), 'join_table_alias': alias for the final table to be joined against (usually a module main table)
|
$return_array |
bool |
if true the query is returned as a array broken up into select, join, where, type, rel_key, and joined_tables |
Returns
Type |
Description |
\string/array |
join query for this link |
getQuery(
array $params
=
array()
)
:
\String/Array
Parameters
Name |
Type |
Description |
$params |
array |
optional parameters. Possible Values; 'return_as_array': returns the query broken into
|
Returns
Type |
Description |
\String/Array |
query to grab just ids for this relationship |
getRelatedBean(
bool $id
=
false
)
:
\SugarBean
Parameters
Name |
Type |
Description |
$id |
bool |
id of related record to retrieve |
Returns
getSubpanelQuery(
\$params $params
=
array(), bool $return_array
=
false
)
:
\string/array
This function is similair getJoin except for M2m relationships it won't join agaist the final table.
Its used to retrieve the ID of the related beans only
Parameters
Name |
Type |
Description |
$params |
\$params |
array of parameters. Possible parameters include: 'return_as_array': returns the query broken into
|
$return_array |
bool |
same as passing 'return_as_array' into parameters
|
Returns
Type |
Description |
\string/array |
query to use when joining for subpanels |
load(
$params
=
array()
)
:
void
inheritedForces the link to load the relationship rows.
Inherited from:
\Link2::load()
Will be called internally when the $rows property is accessed or get() is called
Parameters
Name |
Type |
Description |
$params |
|
|
query(
array $params
)
:
void
inheritedPerform a query on this relationship.
Inherited from:
\Link2::query()
Parameters
Name |
Type |
Description |
$params |
array |
An array that can contain the following parameters:
|
relationship_exists(
\$table_name $table_name, \$join_key_values $join_key_values
)
:
bool
inheritedDirectly queries the databse for set of values. The relationship classes and not link should handle this.
Inherited from:
\Link2::relationship_exists()
Parameters
Name |
Type |
Description |
$table_name |
\$table_name |
string relationship table |
$join_key_values |
\$join_key_values |
array of key=>values to identify this relationship by
|
Returns
Type |
Description |
bool |
true if the given join key set exists in the relationship table |
removeBean(
\SugarBean $bean
)
:
void
inheritedRemove a bean object from the list of beans currently loaded to this relationship.
Inherited from:
\Link2::removeBean()
This for the most part should not need to be called except by the relatipnship implementation classes.
Parameters