GRIS_INSTITUTE
extends GRIS_CLASS_TEMPLATE
in package
Class for intitutes
With this class the institute table can be managed.
PHP version 7
Copyright (c) 2012, Holger Heuser
Tags
Table of Contents
- dbtable = 'gris_institute'
- The constant for the database table
- settings_group = "gris_institute"
- 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
- __construct() : mixed
- The class constructor
- debug() : bool
- Output the full dataset without object data (all subobjects are parsed recursively)
- delete() : bool
- Delete all data for a given institute ID (in the database) WARNING: No reference check!
- delete_all() : bool
- Delete all data for a given institute ID (in the database) WARNING: No reference check!
- 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_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_institute_id() : string
- Get the corresponding ID to a given city, street and number
- get_institute_list() : array<string|int, mixed>
- Get a list of all institutes
- get_references() : array<string|int, mixed>
- Get all references of a given institute
- 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)
- replace_references() : bool
- Delete all reference entries of a given institute (not the reffering objects)
- reset() : bool
- Reset the whole object (ID = NULL, full_data is empty)
- set() : bool
- Set data in the object
- unset_attribute() : bool
- Unsets an attribute
- update() : bool
- Read or update all data from the institute 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_institute'
settings_group
The constant for the settings group
public
mixed
settings_group
= "gris_institute"
Properties
$classname
The name of the class
protected
object
$classname
= NULL
Tags
$dbconnection
The database object for managing the connection
protected
object
$dbconnection
= NULL
Tags
$full_data
The dataset of the resource information
protected
array<string|int, mixed>
$full_data
= array()
Tags
$i18n
The object for translations
protected
object
$i18n
Tags
$id
The current object ID
protected
object
$id
Tags
$settings
The object for settings
protected
object
$settings
= null
Tags
$state
The object for state
protected
object
$state
Tags
$xml_data
The data as xml string
protected
string
$xml_data
= NULL
Tags
Methods
__construct()
The class constructor
public
__construct([string $id = NULL ]) : mixed
Parameters
- $id : string = NULL
-
The institute ID
Initializes the objects
Return values
mixed —debug()
Output the full dataset without object data (all subobjects are parsed recursively)
public
debug() : bool
Return values
bool —true
delete()
Delete all data for a given institute ID (in the database) WARNING: No reference check!
public
delete() : bool
Return values
bool —Returns true for success and false if the entry as still references somewhere or no ID given
delete_all()
Delete all data for a given institute ID (in the database) WARNING: No reference check!
public
delete_all(int $id) : bool
Parameters
- $id : int
-
The ID of the institute
Return values
bool —Returns true for success and false if the entry as still references somewhere or no ID given
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_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_institute_id()
Get the corresponding ID to a given city, street and number
public
get_institute_id(string $city, string $street, string $streetnumber) : string
Parameters
- $city : string
-
The city
- $street : string
-
The street
- $streetnumber : string
-
The number
Return values
string —The ID of the address (returns NULL if no ID was found)
get_institute_list()
Get a list of all institutes
public
get_institute_list([bool $internal = false ][, bool $ref = false ]) : array<string|int, mixed>
Parameters
- $internal : bool = false
-
Return only intenal institutes
- $ref : bool = false
-
Add reference count to each entry
Return values
array<string|int, mixed> —The array with the institutes (returns false if no institute was found)
get_references()
Get all references of a given institute
public
get_references(int $id[, bool $ref_count = false ]) : array<string|int, mixed>
Parameters
- $id : int
-
The ID of the institute
- $ref_count : bool = false
-
Return only the count of references
Return values
array<string|int, mixed> —The array with all references or false on error
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. Returns -1 (int), if the institute already exists
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)
replace_references()
Delete all reference entries of a given institute (not the reffering objects)
public
replace_references(int $id[, mixed $replacement = "NULL" ]) : bool
Parameters
- $id : int
-
The ID of the institute
- $replacement : mixed = "NULL"
Return values
bool —True on succes or false on 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 institute (data will be merged, same attributes will be overwritten)
- $writethrough : bool = false
-
Write the object to the database immediately
Return values
bool —Returns true for success and false for no data given. Returns -1 (int), if the institute already exists.
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 institute table of the db into an array
public
update(string $id[, bool $temp = false ]) : bool
This method replaces get_institute_data($id)
Parameters
- $id : string
-
The ID of the institute (should also work with an int param)
- $temp : bool = false
-
Just return the data without writing it to the object attributes (if true)
Return values
bool —Returns true for success and false for institute not found
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