[ Index ]
 

Code source de Horde 3.1.3

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/Horde/DataTree/ -> sql.php (sommaire)

(pas de description)

Poids: 1639 lignes (64 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

DataTree_sql:: (27 méthodes):
  DataTree_sql()
  getGroups()
  _load()
  _count()
  _buildLoadQuery()
  _buildParentIds()
  _loadById()
  getSortedTree()
  add()
  reorder()
  setOrder()
  remove()
  removeByIds()
  removeByNames()
  move()
  rename()
  getData()
  getAttributes()
  countByAttributes()
  getByAttributes()
  sortByAttributes()
  getAttributeValues()
  buildAttributeQuery()
  _buildAttributeQuery()
  _getAlias()
  updateData()
  _connect()


Classe: DataTree_sql  - X-Ref

The DataTree_sql:: class provides an SQL implementation of the Horde
DataTree system.

Required parameters:<pre>
'phptype'   The database type (ie. 'pgsql', 'mysql', etc.).
'charset'   The charset used by the database.</pre>

Optional parameters:<pre>
'table'     The name of the data table in 'database'.
DEFAULT: 'horde_datatree'</pre>

Required by some database implementations:<pre>
'database'  The name of the database.
'username'  The username with which to connect to the database.
'password'  The password associated with 'username'.
'hostspec'  The hostname of the database server.
'protocol'  The communication protocol ('tcp', 'unix', etc.).
'options'   Additional options to pass to the database.
'port'      The port on which to connect to the database.
'tty'       The TTY on which to connect to the database.</pre>

The table structure for the DataTree system is in
scripts/sql/horde_datatree.sql.

$Horde: framework/DataTree/DataTree/sql.php,v 1.156.2.30 2006/07/13 09:04:20 jan Exp $

Copyright 1999-2006 Stephane Huther <shuther@bigfoot.com>
Copyright 2001-2006 Chuck Hagenbuch <chuck@horde.org>
Copyright 2005-2006 Jan Schneider <jan@horde.org>

See the enclosed file COPYING for license information (LGPL). If
you did not receive this file, see
http://www.fsf.org/copyleft/lgpl.html.

DataTree_sql($params)   X-Ref
Constructs a new SQL DataTree object.

param: array $params  A hash containing connection parameters.

getGroups()   X-Ref
Returns a list of all groups (root nodes) of the data tree.

return: array  The the group IDs

_load($root = DATATREE_ROOT, $loadTree = false, $reload = false,$sortby_name = null, $sortby_key = null, $direction = 0)   X-Ref
Loads (a subset of) the datatree into the $_data array.

param: string  $root         Which portion of the tree to load.
param: boolean $loadTree     Load a tree starting at $root, or just the
param: boolean $reload       Re-load already loaded values?
param: string  $sortby_name  Attribute name to use for sorting.
param: string  $sortby_key   Attribute key to use for sorting.
param: integer $direction    Sort direction:
return: mixed  True on success or a PEAR_Error on failure.

_count($root = DATATREE_ROOT)   X-Ref
Counts (a subset of) the datatree which would be loaded into the $_data
array if _load() is called with the same value of $root.

param: string $root  Which portion of the tree to load. Defaults to all
return: integer  Number of objects

_buildLoadQuery($root = DATATREE_ROOT, $loadTree = false,$operation = DATATREE_BUILD_SELECT,$sortby_name = null, $sortby_key = null,$direction = 0)   X-Ref
Loads (a subset of) the datatree into the $_data array.

param: string  $root         Which portion of the tree to load.
param: boolean $loadTree     Load a tree starting at $root, or just the
param: integer $operation    Type of query to build
param: string  $sortby_name  Attribute name to use for sorting.
param: string  $sortby_key   Attribute key to use for sorting.
param: integer $direction    Sort direction:
return: mixed  True on success or a PEAR_Error on failure.

_buildParentIds($root, $loadTree = false, $join_name = '')   X-Ref
Builds parent ID string for selecting trees.

param: string  $root      Which portion of the tree to load.
param: boolean $loadTree  Load a tree starting at $root, or just the
param: string  $join_name Table join name
return: string  Id list.

_loadById($cids)   X-Ref
Loads a set of objects identified by their unique IDs, and their
parents, into the $_data array.

param: mixed $cids  The unique ID of the object to load, or an array of
return: mixed  True on success or a PEAR_Error on failure.

getSortedTree($root, $loadTree = false, $sortby_name = null,$sortby_key = null, $direction = 0)   X-Ref
Returns a tree sorted by the specified attribute name and/or key.

param: string $root         Which portion of the tree to sort.
param: boolean $loadTree    Sort the tree starting at $root, or just the
param: string $sortby_name  Attribute name to use for sorting.
param: string $sortby_key   Attribute key to use for sorting.
param: integer $direction   Sort direction:

add($object, $id_as_name = false)   X-Ref
Adds an object.

param: mixed $object        The object to add (string or
param: boolean $id_as_name  Whether the object ID is to be used as

reorder($parent, $order = null, $cid = null)   X-Ref
Changes the order of the children of an object.

param: string $parent  The full id path of the parent object.
param: mixed $order    If an array it specifies the new positions for
param: integer $cid    See $order.

setOrder($id, $order)   X-Ref
Explicitly set the order for a datatree object.

param: integer $id     The datatree object id to change.
param: integer $order  The new order.

remove($object, $force = false)   X-Ref
Removes an object.

param: mixed   $object  The object to remove.
param: boolean $force   Force removal of every child object?

removeByIds($ids)   X-Ref
Removes one or more objects by id.

This function does *not* do the validation, reordering, etc. that
remove() does. If you need to check for children, re-do ordering, etc.,
then you must remove() objects one-by-one. This is for code that knows
it's dealing with single (non-parented) objects and needs to delete a
batch of them quickly.

param: array $ids  The objects to remove.

removeByNames($names)   X-Ref
Removes one or more objects by name.

This function does *not* do the validation, reordering, etc. that
remove() does. If you need to check for children, re-do ordering, etc.,
then you must remove() objects one-by-one. This is for code that knows
it's dealing with single (non-parented) objects and needs to delete a
batch of them quickly.

param: array $names  The objects to remove.

move($object, $newparent = null)   X-Ref
Move an object to a new parent.

param: mixed  $object     The object to move.
param: string $newparent  The new parent object. Defaults to the root.

rename($old_object, $new_object_name)   X-Ref
Change an object's name.

param: mixed  $old_object       The old object.
param: string $new_object_name  The new object name.

getData($cid)   X-Ref
Retrieves data for an object from the datatree_data field.

param: integer $cid  The object id to fetch, or an array of object ids.

getAttributes($cid, $keys = false)   X-Ref
Retrieves data for an object from the horde_datatree_attributes table.

param: integer|array $cid  The object id to fetch, or an array of
param: array $keys         The attributes keys to fetch.
return: array  A hash of attributes, or a multi-level hash of object

countByAttributes($criteria, $parent = DATATREE_ROOT,$allLevels = true, $restrict = 'name')   X-Ref
Returns the number of objects matching a set of attribute criteria.

param: array   $criteria   The array of criteria.
param: string  $parent     The parent node to start searching from.
param: boolean $allLevels  Return all levels, or just the direct
param: string  $restrict   Only return attributes with the same

getByAttributes($criteria, $parent = DATATREE_ROOT,$allLevels = true, $restrict = 'name', $from = 0,$count = 0, $sortby_name = null,$sortby_key = null, $direction = 0)   X-Ref
Returns a set of object ids based on a set of attribute criteria.

param: array   $criteria     The array of criteria.
param: string  $parent       The parent node to start searching from.
param: boolean $allLevels    Return all levels, or just the direct
param: string  $restrict     Only return attributes with the same
param: integer $from         The object to start to fetching
param: integer $count        The number of objects to fetch
param: string  $sortby_name  Attribute name to use for sorting.
param: string  $sortby_key   Attribute key to use for sorting.
param: integer $direction    Sort direction:

sortByAttributes($unordered_ids, $sortby_name = null,$sortby_key = null, $direction = 0)   X-Ref
Sorts IDs by attribute values. IDs without attributes will be added to
the end of the sorted list.

param: array $unordered_ids  Array of ids to sort.
param: array $sortby_name    Attribute name to use for sorting.
param: array $sortby_key     Attribute key to use for sorting.
param: array $direction      Sort direction:
return: array  Sorted ids.

getAttributeValues($attribute_name = null, $attribute_key = null,$parent = DATATREE_ROOT, $allLevels = true)   X-Ref
Returns a list of all of the available values of the given attribute
name/key combination. Either attribute_name or attribute_key MUST be
supplied, and both MAY be supplied.

param: string  $attribute_name  The name of the attribute.
param: string  $attribute_key   The key value of the attribute.
param: string  $parent          The parent node to start searching from.
param: boolean $allLevels       Return all levels, or just the direct
return: array  An array of all of the available values.

buildAttributeQuery($criteria, $parent = DATATREE_ROOT,$allLevels = true, $restrict = 'name',$operation = DATATREE_BUILD_SELECT,$sortby_name = null, $sortby_key = null,$direction = 0)   X-Ref
Builds an attribute query. Here is an example $criteria array:

<code>
$criteria['OR'] = array(
array('AND' => array(
array('field' => 'name',
'op'    => '=',
'test'  => 'foo'),
array('field' => 'key',
'op'    => '=',
'test'  => 'abc'))),
array('AND' => array(
array('field' => 'name',
'op'    => '=',
'test'  => 'bar'),
array('field' => 'key',
'op'    => '=',
'test'  => 'xyz'))));
</code>

This would fetch all object ids where attribute name is "foo" AND key
is "abc", OR "bar" AND "xyz".

param: array   $criteria     The array of criteria.
param: string  $parent       The parent node to start searching from.
param: boolean $allLevels    Return all levels, or just the direct
param: string  $restrict     Only return attributes with the same
param: integer $operation    Type of query to build
param: string  $sortby_name  Attribute name to use for sorting.
param: string  $sortby_key   Attribute key to use for sorting.
param: integer $direction    Sort direction:
return: array  An SQL query and a list of values suitable for binding

_buildAttributeQuery($glue, $criteria, $join = false)   X-Ref
Builds a piece of an attribute query.

param: string $glue     The glue to join the criteria (OR/AND).
param: array $criteria  The array of criteria.
param: boolean $join    Should we join on a clean
return: array  An SQL fragment and a list of values suitable for binding

_getAlias($increment = false)   X-Ref
Get an alias to horde_datatree_attributes, incrementing it if
necessary.

param: boolean $increment  Increment the alias count? Defaults to no.

updateData($object)   X-Ref
Update the data in an object. Does not change the object's
parent or name, just serialized data or attributes.

param: DataTree $object  A DataTree object.

_connect()   X-Ref
Attempts to open a connection to the SQL server.

return: boolean  True.



Généré le : Sun Feb 25 18:01:28 2007 par Balluche grâce à PHPXref 0.7