data/Link2.php

Show: inherited
Table of Contents

\Link2

Package: SugarCRM

Represents a relationship from a single beans perspective.

Children
\AccountLink
\ProspectLink
Api
 

Properties

Propertyprotected  $beans= ''
Details
Type
n/a
Propertyprotected  $def= ''
Details
Type
n/a
Propertyprotected  $focus= ''
Details
Type
n/a
Propertyprotected  $loaded= ''
Details
Type
n/a
Propertyprotected  $name= ''
Details
Type
n/a
Propertyprotected  $relationship= ''
Details
Type
n/a
Propertyprotected  $relationship_fields= 'array()'
Default valuearray()Details
Type
n/a
Propertyprotected  $rows= ''
Details
Type
n/a
Propertyprotected  $tempBeans= 'array()'
Default valuearray()Details
Type
n/a

Methods

methodpublic__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

methodpublic__get(  $name ) : void

Parameters
Name Type Description
$name
methodpublic__set(  $name,  $val ) : void

Parameters
Name Type Description
$name
$val
methodpublic_get_alternate_key_fields(  $table_name ) : void

Parameters
Name Type Description
$table_name
methodpublic_get_bean_position( ) : boolean

Returns
Type Description
boolean returns true if this link is LHS
Details
Deprecated
 
methodpublic_get_link_table_definition(  $table_name,  $def_name ) : void

Parameters
Name Type Description
$table_name
$def_name
Details
Deprecated
Gets the vardef for the relationship of this link.  
methodpublic_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
Details
Deprecated
Return the name of the role field for the passed many to many table. if there is no role filed : return false  
methodpublicadd( array $rel_keys, array $additional_values = array() ) : boolean | array

use this function to create link between 2 objects 1:1 will be treated like 1 to many.

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.
methodpublicaddBean( \SugarBean $bean ) : void

Add a bean object to the list of beans currently loaded to this relationship.

This for the most part should not need to be called except by the relatipnship implementation classes.

Parameters
Name Type Description
$bean \SugarBean
methodpublicbeansAreLoaded( ) : bool

Returns
Type Description
bool true if this link has initialized its related beans.
methodpublicdelete( \$id $id, string $related_id = '' ) : boolean

Marks the relationship delted for this given record pair.

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
methodpublicget(  $role = false ) : array

Parameters
Name Type Description
$role
Returns
Type Description
array ids of records related through this link
methodpublicgetBeans( array $params = array() ) : array

Use 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.

Parameters
Name Type Description
$params array

An array that can contain the following parameters:

  • where: An array with 3 key/value pairs. lhs_field: The name of the field to check search. operator: The operator to use in the search. rhs_value: The value to search for.
    Example:
     'where' => array( 'lhs_field' => 'source', 'operator' => '=', 'rhs_value' => 'external' )
  • limit: The maximum number of beans to load.
  • deleted: If deleted is set to 1, only deleted records related to the current record will be returned.
Returns
Type Description
array of SugarBeans related through this link.
methodpublicgetFocus( ) : \SugarBean

Returns
Type Description
\SugarBean The parent Bean this link references
methodpublicgetJoin( \$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
methodpublicgetQuery( 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
methodprotectedgetRelatedBean( bool $id = false ) : \SugarBean

Returns a SugarBean with the given ID from the related module.

Parameters
Name Type Description
$id bool

id of related record to retrieve

Returns
Type Description
\SugarBean
methodpublicgetRelatedField(  $name ) : \The

Parameters
Name Type Description
$name
Returns
Type Description
\The value for the relationship field $name
methodpublicgetRelatedFields( ) : \list

Returns
Type Description
\list of fields that exist only on the relationship
Details
Deprecated
 
methodpublicgetRelatedModuleLinkName( ) : string

Returns
Type Description
string the name of the link field used on the other side of the rel
methodpublicgetRelatedModuleName( ) : string

Returns
Type Description
string the name of the module on the other side of this link
methodpublicgetRelatedTableName( ) : string

Returns
Type Description
string name of table for the relationship of this link
Details
Deprecated
 
methodpublicgetRelationshipObject( ) : \SugarRelationship

Returns
Type Description
\SugarRelationship the relationship object this link references
methodpublicgetSide( ) : string

Returns
Type Description
string "LHS" or "RHS" depending on the side of the relationship this link represents
methodpublicgetSubpanelQuery( \$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
methodpublicgetType( ) : string

Returns
Type Description
string "many" if multiple records can be related through this link or "one" if at most, one record can be related.
methodpublicisParentRelationship( ) : bool

Returns
Type Description
bool true if this link represents a relationship where the parent could be one of multiple modules. (ex. Activities parent)
methodprotectedis_self_relationship( ) : bool

Returns
Type Description
bool true if LHSModule == RHSModule
methodpublicload(  $params = array() ) : void

Forces the link to load the relationship rows.

Will be called internally when the $rows property is accessed or get() is called

Parameters
Name Type Description
$params
methodpublicloadedSuccesfully( ) : bool

Returns false if no relationship was found for this link

Returns
Type Description
bool
methodpublicquery( array $params ) : void

Perform a query on this relationship.

Parameters
Name Type Description
$params array

An array that can contain the following parameters:

  • where: An array with 3 key/value pairs. lhs_field: The name of the field to check search. operator: The operator to use in the search. rhs_value: The value to search for.
    Example:
     'where' => array( 'lhs_field' => 'source', 'operator' => '=', 'rhs_value' => 'external' )
  • limit: The maximum number of rows
  • deleted: If deleted is set to 1, only deleted records related to the current record will be returned.
methodpublicrelationship_exists( \$table_name $table_name, \$join_key_values $join_key_values ) : bool

Directly queries the databse for set of values. The relationship classes and not link should handle this.

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
Details
Deprecated
 
methodpublicremoveBean( \SugarBean $bean ) : void

Remove a bean object from the list of beans currently loaded to this relationship.

This for the most part should not need to be called except by the relatipnship implementation classes.

Parameters
Name Type Description
$bean \SugarBean
Documentation was generated by DocBlox 0.18.1.