PHP Class Hylax_SQL_Attributes, horde

Copyright 1999-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Author: Chuck Hagenbuch ([email protected])
ファイルを表示 Open project: horde/horde

Public Properties

Property Type Description
$_db DB The PEAR::DB object to run queries with.
$_params array primary_table - The main table name. attribute_table - The table that the attributes are stored in.
$_table_count integer The number of copies of the attributes table that we need to join on in the current query.

Public Methods

Method Description
Hylax_SQL_Attributes ( DB $dbh, array $params ) Constructor.
_buildAttributeQuery ( string $glue, array $criteria, boolean $join = false ) : string Build a piece of an attribute query.
_getAlias ( boolean $increment = false ) Get an alias to an attributes table, incrementing it if necessary.
deleteAttributes ( integer $id ) Given an id, delete all attributes for that id from the attributes table.
getAttributes ( integer | array $id ) : array Returns all attributes for a given id or multiple ids.
getByAttributes ( array $criteria ) Return a set of ids based on a set of attribute criteria.
insertAttributes ( integer $id, array $attributes ) Given a new attribute set and an id, insert each into the DB. If anything fails in here, rollback the transaction, return the relevant error and bail out.
updateAttributes ( integer $id, array $attributes ) Given an id, update all attributes for that id in the attributes table with the new attributes.

Method Details

Hylax_SQL_Attributes() public method

Constructor.
public Hylax_SQL_Attributes ( DB $dbh, array $params )
$dbh DB A PEAR::DB object.
$params array The id column, table names, etc.

_buildAttributeQuery() public method

Build a piece of an attribute query.
public _buildAttributeQuery ( string $glue, array $criteria, boolean $join = false ) : string
$glue string The glue to join the criteria (OR/AND).
$criteria array The array of criteria.
$join boolean Should we join on a clean attributes table?
return string An SQL fragment.

_getAlias() public method

Get an alias to an attributes table, incrementing it if necessary.
public _getAlias ( boolean $increment = false )
$increment boolean Increment the alias count? Defaults to false.

deleteAttributes() public method

Given an id, delete all attributes for that id from the attributes table.
public deleteAttributes ( integer $id )
$id integer The id of the record for which attributes are being deleted.

getAttributes() public method

Returns all attributes for a given id or multiple ids.
public getAttributes ( integer | array $id ) : array
$id integer | array
return array A hash of attributes, or a multi-level hash of ids => their attributes.

getByAttributes() public method

Return a set of ids based on a set of attribute criteria.
public getByAttributes ( array $criteria )
$criteria array The array of criteria. Example: $criteria['OR'] = array( array('field' => 'name', 'op' => '=', 'test' => 'foo'), array('field' => 'name', 'op' => '=', 'test' => 'bar')); This would return all ids for which the field attribute_name is either 'foo' or 'bar'.

insertAttributes() public method

Given a new attribute set and an id, insert each into the DB. If anything fails in here, rollback the transaction, return the relevant error and bail out.
public insertAttributes ( integer $id, array $attributes )
$id integer The id of the record for which attributes are being inserted.
$attributes array An hash containing the attributes.

updateAttributes() public method

Given an id, update all attributes for that id in the attributes table with the new attributes.
public updateAttributes ( integer $id, array $attributes )
$id integer The id of the record for which attributes are being deleted.
$attributes array An hash containing the attributes.

Property Details

$_db public_oe property

The PEAR::DB object to run queries with.
public DB $_db
return DB

$_params public_oe property

primary_table - The main table name. attribute_table - The table that the attributes are stored in.
public array $_params
return array

$_table_count public_oe property

The number of copies of the attributes table that we need to join on in the current query.
public int $_table_count
return integer