Documentation is available at core_functions_relationships.php
- <?php /*
- function core_get_type_sets( $field = NULL ) {
- //returns an array of all defined type sets - if field specified returns on that field
- global $db;
- $selectField = $field ? ( "id, ".$field ) : "*";
- $return_array = $db->get_results( "SELECT ".$selectField." FROM type_sets", ARRAY_A );
- return $return_array;
- }
- function core_get_type_set( $type_setID ) {
- //gets the specified type set's values
- global $db;
- $return_array = $db->get_results( "SELECT * FROM type_sets WHERE id = '".$type_setID."'", ARRAY_A );
- return $return_array;
- }
- function core_get_relationship_types( $field = NULL ) {
- //returns an array of all defined relationship types - if field specified returns on that field
- global $db;
- $selectField = $field ? ( "id, ".$field ) : "*";
- $return_array = $db->get_results( "SELECT ".$selectField." FROM object_types", ARRAY_A );
- return $return_array;
- }
- function core_get_relationship_type( $relationshipID ) {
- //gets the specified relationship type's values
- global $db;
- $return_array = array();
- if( $relationshipID == "*new*" ) {
- $newID = new_relationship_type();
- return core_get_relationship_type( $newID );
- } else {
- $return_array = $db->get_results( "SELECT * FROM object_types WHERE id = '".$relationshipID."'", ARRAY_A );
- }
- return $return_array[0];
- }
- function get_relationship_type_index( $relationshipID ) {
- //relationship type implementation of get_object_index()
- $relationshipType = core_get_relationship_type( $relationshipID );
- if( $relationshipType['name'] ) {
- $relationshipTypeIndex = $relationshipType['name'];
- } else {
- $relationshipTypeIndex = "new user type";
- }
- return $relationshipTypeIndex;
- }
- function get_type_set_index( $typeSetID ) {
- //relationship type implementation of get_object_index()
- $typeSet = core_get_type_set( $typeSetID );
- if( $typeSet['name'] ) {
- $typeSetIndex = $typeSet['name'];
- } else {
- $typeSetIndex = "new type set";
- }
- return $typeSetIndex;
- }
- function get_type_set( $typeSetID ) {
- //gets the specified type set's values
- global $db;
- $return_array = array();
- if( $typeSetID == "*new*" ) {
- $newID = new_type_set();
- return get_type_set( $newID );
- } else {
- $return_array = $db->get_results( "SELECT * FROM type_sets WHERE id = '".$typeSetID."'", ARRAY_A );
- }
- return $return_array[0];
- }
- function core_get_relationship_type_ID( $name = NULL, $description = NULL ) {
- //adds or updates a new/existing person to the person table and returns the new person's id
- global $db;
- $variableCount = 0;
- $selectString = "SELECT id FROM object_types";
- if( $name ) { $selectString = $selectString.($variableCount? " AND ":" WHERE ")."name = '".$name."'"; $variableCount++; }
- if( $description ) { $selectString = $selectString.($variableCount? " AND ":" WHERE ")."description = '".$description."'"; $variableCount++; }
- if( !$name && !$description ) {
- $selectString = $selectString."
- WHERE name is NULL
- AND description is NULL";
- }
- $db->hide_errors();
- $returnArray = $db->get_results( clean($selectString), ARRAY_A );
- $db->show_errors();
- return $returnArray[0]['id'];
- }
- */
- function get_type_set_ID( $relationshipTypeID = NULL, $primaryConstraintID = NULL, $secondaryConstraintID = NULL, $biDirectional = NULL ) {
- //adds or updates a new/existing person to the person table and returns the new person's id
- global $db;
- $variableCount = 0;
- $selectString = "SELECT id FROM type_sets";
- if( $relationshipTypeID ) { $selectString = $selectString.($variableCount? " AND ":" WHERE ")."relationship_typeID = '".$relationshipTypeID."'"; $variableCount++; }
- if( $primaryConstraintID ) { $selectString = $selectString.($variableCount? " AND ":" WHERE ")."primary_constraintID = '".$primaryConstraintID."'"; $variableCount++; }
- if( $secondaryConstraintID ) { $selectString = $selectString.($variableCount? " AND ":" WHERE ")."secondary_constraintID = '".$secondaryConstraintID."'"; $variableCount++; }
- if( $biDirectional ) { $selectString = $selectString.($variableCount? " AND ":" WHERE ")."bi_directional = '".$biDirectional."'"; $variableCount++; }
- if( !$relationshipTypeID && !$primaryConstraintID && !$secondaryConstraintID && !$biDirectional ) {
- $selectString = $selectString."
- WHERE relationship_typeID is NULL
- AND primary_constraintID is NULL
- AND secondary_constraintID is NULL
- AND bi_directional is NULL
- ";
- }
- $db->hide_errors();
- $returnArray = $db->get_results( clean($selectString), ARRAY_A );
- $db->show_errors();
- return $returnArray[0]['id'];
- }
- /*
- function set_relationship_type( $id, $name, $description = NULL ) {
- global $db;
- if( $name || $description ) {
- $variableCount = 0;
- $updateString = "UPDATE object_types SET ";
- if( isset($name) ) { $updateString = $updateString.($variableCount?", ":"")."name = '".clean($name)."'"; $variableCount++; }
- if( isset($description) ) { $updateString = $updateString.($variableCount?", ":"")."description = '".clean($description)."'"; $variableCount++; }
- $updateString = $updateString." WHERE id = '".$id."'";
- $db->query( $updateString );
- }
- }
- function set_type_set( $id, $type, $primary, $secondary, $bi ) {
- global $db;
- if( $type || $primary || $secondary || $bi ) {
- $variableCount = 0;
- $updateString = "UPDATE type_sets SET ";
- if( isset($type) ) { $updateString = $updateString.($variableCount?", ":"")."relationship_typeID = '".clean($type)."'"; $variableCount++; }
- if( isset($primary) ) { $updateString = $updateString.($variableCount?", ":"")."primary_constraintID = '".clean($primary)."'"; $variableCount++; }
- if( isset($secondary) ) { $updateString = $updateString.($variableCount?", ":"")."secondary_constraintID = '".clean($secondary)."'"; $variableCount++; }
- if( isset($bi) ) { $updateString = $updateString.($variableCount?", ":"")."bi_directional = '".clean($bi)."'"; $variableCount++; }
- $updateString = $updateString." WHERE id = '".$id."'";
- $db->query( $updateString );
- }
- }
- function set_constraint( $id, $name = NULL, $description = NULL, $objectConstraints = NULL, $relationshipConstraints = NULL ) {
- //this function defines a new constraint
- global $db;
- $objectConstraintsString = ( is_array($objectConstraints) ? serialize( $objectConstraints ) : $objectConstraints );
- $relationshipConstraintsString = ( is_array($relationshipConstraints) ? serialize( $relationshipConstraints ) : $relationshipConstraints );
- $db->query( "UPDATE constraints SET description = '".($description)."', object_constraints = '".$objectConstraintsString."', relationship_constraints = '".$relationshipConstraintsString."' WHERE id = '".$id."'" );
- }
- function new_type_set( $relationshipTypeID = NULL, $primaryConstraintID = NULL, $secondaryConstraintID = NULL, $biDirectional = NULL ) {
- //sets the values of the given relationship type to the given values
- global $db;
- $typeSetID = get_type_set_ID( $relationshipTypeID, $primaryConstraintID, $secondaryConstraintID, $biDirectional );
- //if the relationship type is new, insert it into the types table
- if( !$typeSetID ) {
- $typeSetID = $db->get_var( "SELECT value FROM system_settings WHERE name = 'type_sets_counter'" );
- $db->query( "
- INSERT INTO type_sets
- ( id ) VALUES ( '".$typeSetID."' )
- " );
- $db->query( "UPDATE system_settings SET value = '".($typeSetID + 1)."' WHERE name = 'type_sets_counter'" );
- }
- set_type_set_withNames( $typeSetID, $relationshipTypeID, $primaryConstraintID, $secondaryConstraintID, $biDirectional );
- return $typeSetID;
- }
- function delete_type_set( $id ) {
- //deletes a type set
- global $db;
- }
- function delete_constraint( $id ) {
- //deletes a type set
- global $db;
- }
- */
- ?>
Documentation generated on Tue, 24 May 2005 03:57:47 -0400 by phpDocumentor 1.3.0RC3