Documentation

GRIS_RELATION extends GRIS_CLASS_TEMPLATE
in package

Class for relations between two tables

With this class the relations between two tables can be managed.

PHP version 7

Copyright (c) 2012, Holger Heuser

Tags
copyright

Copyright (c) 2012, Holger Heuser

link
http://git.gesis.org/gris
since
2

File available since Release 2.0

version
2.0
author

Holger Heuser holger.heuser@gesis.org

Table of Contents

dbtable  = 'gris_relations'
The constant for the database table
settings_group  = "relations"
The constant for the settings group
$classname  : object
The name of the class
$dbconnection  : object
The database object for managing the connection
$full_data  : array<string|int, mixed>
The dataset of the resource information
$i18n  : object
The object for translations
$id  : object
The current object ID
$settings  : object
The object for settings
$state  : object
The object for state
$xml_data  : string
The data as xml string
$object_table  : object
The object table
__construct()  : mixed
The class constructor
add_details()  : bool
Add detailed data for institutes and personnames
append()  : bool
Append a role (with duplicate check)
debug()  : bool
Output the full dataset without object data (all subobjects are parsed recursively)
delete_relations()  : bool
Delete all relations
get()  : array<string|int, mixed>|object|string
Returns an array of the full data or (if given) only certain attributes (separated by "|" for a subattribute)
get_ac_list()  : bool
Returns items for autocomplete.
get_flat_data()  : array<string|int, mixed>
Get the data in a flat format. From subarrays only the first entry is merged
get_flat_data_old()  : array<string|int, mixed>
Get the data in a flat format. From subarrays only the first entry is merged
get_related_persons()  : bool
Get all personname (person) relations from an object
get_relation()  : array<string|int, mixed>
Get the relation data by ID
id()  : int
Set a new ID or return the current ID if $id is NULL. The numeric value 0 is also set to NULL.
persist()  : bool
Persist the object data to the database
pull_json()  : string
Returns the object data as JSON
pull_xml()  : string
Returns the object data as XML
push_xml()  : bool
Push an xml into the object (experimental, not finished yet)
relation_exists()  : bool
Check if relations exist. If ID or table are not NULL the existance of only that single entry is checked. Otherwise the method checks independant from a special subject wether there is one or more entries for that role or not.
reset()  : bool
Reset the whole object (ID = NULL, full_data is empty)
set()  : bool
Set data in the object
set_object_table()  : bool
Setter for the object table
unset_attribute()  : bool
Unsets an attribute
update()  : bool
Read or update all data from the address table of the db into an array
initialize()  : bool
Initializes the object by filling the array with data
array_to_xml()  : bool
Convert an array into an xml representation
out()  : bool
Preformatted output of the variable (for development)

Constants

dbtable

The constant for the database table

public mixed dbtable = 'gris_relations'

settings_group

The constant for the settings group

public mixed settings_group = "relations"

Properties

$classname

The name of the class

protected object $classname = NULL
Tags
access

private

$dbconnection

The database object for managing the connection

protected object $dbconnection = NULL
Tags
access

private

$full_data

The dataset of the resource information

protected array<string|int, mixed> $full_data = array()
Tags
access

private

$settings

The object for settings

protected object $settings = null
Tags
access

private

$xml_data

The data as xml string

protected string $xml_data = NULL
Tags
access

private

$object_table

The object table

private object $object_table = NULL
Tags
access

private

Methods

__construct()

The class constructor

public __construct([string $object_id = NULL ][, string $object_table = NULL ]) : mixed
Parameters
$object_id : string = NULL

The object ID

$object_table : string = NULL

The object table

Initializes the objects

Return values
mixed

add_details()

Add detailed data for institutes and personnames

public add_details() : bool
Return values
bool

Returns true

append()

Append a role (with duplicate check)

public append(string $role, array<string|int, mixed> $data[, bool $writethrough = false ]) : bool
Parameters
$role : string

The role to be appended

$data : array<string|int, mixed>

Data for the role

$writethrough : bool = false

Write the object to the database immediately

Return values
bool

Returns true for success and false for no data given

debug()

Output the full dataset without object data (all subobjects are parsed recursively)

public debug() : bool
Return values
bool

true

delete_relations()

Delete all relations

public delete_relations([ $id = NULL ]) : bool
Parameters
$id : = NULL

The ID of the relation

Return values
bool

Returns true for success or false for error

get()

Returns an array of the full data or (if given) only certain attributes (separated by "|" for a subattribute)

public get([string $attribute = NULL ]) : array<string|int, mixed>|object|string
Parameters
$attribute : string = NULL

The attributes separated by [parent|child]

Return values
array<string|int, mixed>|object|string

The dataset or NULL

get_ac_list()

Returns items for autocomplete.

public get_ac_list(string $gris_relations_role, string $gris_relations_subject_table, string $term) : bool
Parameters
$gris_relations_role : string

The role

$gris_relations_subject_table : string

The table name of the subject

$term : string

The term for autocompletion

Return values
bool

Returns true for success and false for error

get_flat_data()

Get the data in a flat format. From subarrays only the first entry is merged

public get_flat_data([bool $hierarchy = false ][, mixed $data = NULL ]) : array<string|int, mixed>
Parameters
$hierarchy : bool = false

Return full flat (standard) or array hierarchy (if true)

$data : mixed = NULL

Use other data than $this->full_data

Return values
array<string|int, mixed>

The flat data

get_flat_data_old()

Get the data in a flat format. From subarrays only the first entry is merged

public get_flat_data_old([bool $hierarchy = false ][, mixed $data = NULL ]) : array<string|int, mixed>
Parameters
$hierarchy : bool = false

Return full flat (standard) or array hierarchy (if true)

$data : mixed = NULL

Use other data than $this->full_data

Return values
array<string|int, mixed>

The flat data

Get all personname (person) relations from an object

public get_related_persons( $object_table,  $object_id) : bool
Parameters
$object_table :

The name of the object

$object_id :

The ID of the object

Return values
bool

Returns true for success and false for error

get_relation()

Get the relation data by ID

public get_relation( $id) : array<string|int, mixed>
Parameters
$id :

The ID of the relation

Return values
array<string|int, mixed>

Returns the ralation data or NULL if not found

id()

Set a new ID or return the current ID if $id is NULL. The numeric value 0 is also set to NULL.

public id([string $id = NULL ]) : int
Parameters
$id : string = NULL

The current ID

Return values
int

The ID

persist()

Persist the object data to the database

public persist() : bool
Return values
bool

Returns true for success and false for a database error (which can be found in the error object)

pull_json()

Returns the object data as JSON

public pull_json() : string
Return values
string

The json string

pull_xml()

Returns the object data as XML

public pull_xml([bool $head = false ]) : string
Parameters
$head : bool = false

Return XML with head (as default, just a node is returned)

Return values
string

The xml string

push_xml()

Push an xml into the object (experimental, not finished yet)

public push_xml(string $xml) : bool
Parameters
$xml : string

The xml with the object data

Return values
bool

true (or false on error)

relation_exists()

Check if relations exist. If ID or table are not NULL the existance of only that single entry is checked. Otherwise the method checks independant from a special subject wether there is one or more entries for that role or not.

public relation_exists( $gris_relations_role[,  $gris_relations_subject_table = NULL ][,  $gris_relations_subject_id = NULL ]) : bool
Parameters
$gris_relations_role :

The role

$gris_relations_subject_table : = NULL

The table name of the subject

$gris_relations_subject_id : = NULL

The ID of the subject

Return values
bool

Returns true for success and false for error

reset()

Reset the whole object (ID = NULL, full_data is empty)

public reset() : bool
Return values
bool

Returns true

set()

Set data in the object

public set(array<string|int, mixed> $data[, bool $writethrough = false ]) : bool
Parameters
$data : array<string|int, mixed>

One or more new key/values for the object

$writethrough : bool = false

Write the object to the database immediately

Return values
bool

Returns true for success and false for no data given

set_object_table()

Setter for the object table

public set_object_table(string $object_table) : bool
Parameters
$object_table : string

The object table

Return values
bool

Returns true

unset_attribute()

Unsets an attribute

public unset_attribute(string $attribute) : bool
Parameters
$attribute : string

The attributes

Return values
bool

Returns true

update()

Read or update all data from the address table of the db into an array

public update([string $object_id = NULL ]) : bool
Parameters
$object_id : string = NULL

The ID of the object (should also work with an int param)

Return values
bool

Returns true for success and false for error

initialize()

Initializes the object by filling the array with data

protected initialize() : bool
Return values
bool

true (or false on error)

array_to_xml()

Convert an array into an xml representation

private array_to_xml(array<string|int, mixed> $data, Pointer &$xml) : bool
Parameters
$data : array<string|int, mixed>

The array with the data

$xml : Pointer

A pointer to the xml

Return values
bool

true (or NULL if empty)

out()

Preformatted output of the variable (for development)

private out([mixed $mixed = NULL ]) : bool
Parameters
$mixed : mixed = NULL

The variable

Return values
bool

true

Search results