PHP Class Turba_Driver_Sql, horde

Copyright 2010-2016 Horde LLC (http://www.horde.org/) See the enclosed file LICENSE for license information (ASL). If you did did not receive this file, see http://www.horde.org/licenses/apache.
Author: Jon Parise ([email protected])
Author: Michael J. Rubinsky ([email protected])
Inheritance: extends Turba_Driver
Datei anzeigen Open project: horde/horde

Protected Properties

Property Type Description
$_capabilities array What can this backend do?
$_countCache array count() cache.
$_db Horde_Db_Adapter Handle for the current database connection.

Public Methods

Method Description
__construct ( string $name = '', array $params = [] ) Constructor.
count ( ) : integer Returns the number of contacts of the current user in this address book.
getTimeObjectTurbaList ( Horde_Date $start, Horde_Date $end, string $field ) : Turba_List Obtain Turba_List of items to get TimeObjects out of.
removeUserData ( string $user ) Remove all entries owned by the specified user.
searchDuplicates ( ) : array Searches the current address book for duplicate entries.

Protected Methods

Method Description
_add ( array $attributes, array $blob_fields = [], array $date_fields = [] ) Adds the specified object to the SQL database.
_buildFields ( array $array ) : array Prepares field lists for searchDuplicates().
_buildJoin ( array $array ) : array Builds the JOIN conditions for searchDuplicates().
_buildSearchQuery ( string $glue, array $criteria ) : array Builds a piece of a search query.
_buildWhere ( array $array ) : array Builds the WHERE conditions for searchDuplicates().
_canAdd ( ) TODO
_convertFromDriver ( mixed $value ) : mixed Converts a value from the driver's charset to the default charset.
_convertToDriver ( mixed $value ) : mixed Converts a value from the default charset to the driver's charset.
_delete ( $object_key, $object_id ) Deletes the specified object from the SQL database.
_deleteAll ( string $sourceName = null ) : array Deletes all contacts from a specific address book.
_internalSearch ( array $criteria, array $fields, array $blobFields = [], array $appendWhere = [], boolean $count_only = false ) : mixed Searches the SQL database with the given criteria and returns a filtered list of results. If the criteria parameter is an empty array, all records will be returned.
_makeKey ( array $attributes ) : string Creates an object key for a new object.
_parseRead ( $blobFields, $result, $dateFields = [] )
_prepareWrite ( $attributes, $blob_fields, $date_fields )
_read ( string $key, mixed $ids, string $owner, array $fields, array $blobFields = [], array $dateFields = [] ) : array Reads the given data from the SQL database and returns the results.
_save ( Turba_Object $object ) : string Saves the specified object in the SQL database.
_search ( array $criteria, array $fields, array $blobFields = [], boolean $count_only = false ) : array Searches the SQL database with the given criteria and returns a filtered list of results. If the criteria parameter is an empty array, all records will be returned.

Method Details

__construct() public method

Constructor.
public __construct ( string $name = '', array $params = [] )
$name string The source name
$params array Additional parameters needed:
'db' - (Horde_Db_Adapter) A DB Adapter object.

_add() protected method

Adds the specified object to the SQL database.
protected _add ( array $attributes, array $blob_fields = [], array $date_fields = [] )
$attributes array The attribute values of the contact.
$blob_fields array Fields that represent binary data.
$date_fields array Fields that represent dates. @since 4.2.0

_buildFields() protected method

Prepares field lists for searchDuplicates().
protected _buildFields ( array $array ) : array
$array array A list of field names.
return array A prepared list of field names.

_buildJoin() protected method

Builds the JOIN conditions for searchDuplicates().
protected _buildJoin ( array $array ) : array
$array array A list of field names.
return array A list of JOIN conditions.

_buildSearchQuery() protected method

Builds a piece of a search query.
protected _buildSearchQuery ( string $glue, array $criteria ) : array
$glue string The glue to join the criteria (OR/AND).
$criteria array The array of criteria.
return array An SQL fragment and a list of values suitable for binding as an array.

_buildWhere() protected method

Builds the WHERE conditions for searchDuplicates().
protected _buildWhere ( array $array ) : array
$array array A list of field names.
return array A list of WHERE conditions.

_canAdd() protected method

TODO
protected _canAdd ( )

_convertFromDriver() protected method

Converts a value from the driver's charset to the default charset.
protected _convertFromDriver ( mixed $value ) : mixed
$value mixed A value to convert.
return mixed The converted value.

_convertToDriver() protected method

Converts a value from the default charset to the driver's charset.
protected _convertToDriver ( mixed $value ) : mixed
$value mixed A value to convert.
return mixed The converted value.

_delete() protected method

Deletes the specified object from the SQL database.
protected _delete ( $object_key, $object_id )

_deleteAll() protected method

Deletes all contacts from a specific address book.
protected _deleteAll ( string $sourceName = null ) : array
$sourceName string The source to remove all contacts from.
return array An array of UIDs

_internalSearch() protected method

Searches the SQL database with the given criteria and returns a filtered list of results. If the criteria parameter is an empty array, all records will be returned.
protected _internalSearch ( array $criteria, array $fields, array $blobFields = [], array $appendWhere = [], boolean $count_only = false ) : mixed
$criteria array Array containing the search criteria.
$fields array List of fields to return.
$blobFields array TODO
$appendWhere array An additional where clause to append. Array should contain 'sql' and 'params' params are used as bind parameters.
$count_only boolean Only return the count of matching entries, not the entries themselves.
return mixed array|integer Hash containing the search results or the count of matching entries.

_makeKey() protected method

Creates an object key for a new object.
protected _makeKey ( array $attributes ) : string
$attributes array The attributes (in driver keys) of the object being added.
return string A unique ID for the new object.

_parseRead() protected method

protected _parseRead ( $blobFields, $result, $dateFields = [] )

_prepareWrite() protected method

protected _prepareWrite ( $attributes, $blob_fields, $date_fields )

_read() protected method

Reads the given data from the SQL database and returns the results.
protected _read ( string $key, mixed $ids, string $owner, array $fields, array $blobFields = [], array $dateFields = [] ) : array
$key string The primary key field to use.
$ids mixed The ids of the contacts to load.
$owner string Only return contacts owned by this user.
$fields array List of fields to return.
$blobFields array Array of fields containing binary data.
$dateFields array Array of fields containing date data. @since 4.2.0
return array Hash containing the search results.

_save() protected method

Saves the specified object in the SQL database.
protected _save ( Turba_Object $object ) : string
$object Turba_Object The object to save.
return string The object id, possibly updated.

count() public method

Returns the number of contacts of the current user in this address book.
public count ( ) : integer
return integer The number of contacts that the user owns.

getTimeObjectTurbaList() public method

Obtain Turba_List of items to get TimeObjects out of.
public getTimeObjectTurbaList ( Horde_Date $start, Horde_Date $end, string $field ) : Turba_List
$start Horde_Date The starting date.
$end Horde_Date The ending date.
$field string The address book field containing the timeObject information (birthday, anniversary)
return Turba_List Object list.

removeUserData() public method

Remove all entries owned by the specified user.
public removeUserData ( string $user )
$user string The user's data to remove.

searchDuplicates() public method

Duplicates are determined by comparing email and name or last name and first name values.
public searchDuplicates ( ) : array
return array A hash with the following format: array('name' => array('John Doe' => Turba_List, ...), ...)

Property Details

$_capabilities protected_oe property

What can this backend do?
protected array $_capabilities
return array

$_countCache protected_oe property

count() cache.
protected array $_countCache
return array

$_db protected_oe property

Handle for the current database connection.
protected Horde_Db_Adapter $_db
return Horde_Db_Adapter