PHP Class lithium\data\source\http\adapter\CouchDb

Inheritance: extends lithium\data\source\Http
显示文件 Open project: unionofrad/lithium Class Usage Examples

Protected Properties

Property Type Description
$_classes array Classes used by CouchDb.
$_db boolean True if Database exists.
$_handlers
$_iterator string Increment value of current result set loop used by result to handle rows of json responses.

Public Methods

Method Description
__call ( string $method, array $params = [] ) : mixed Magic for passing methods to http service.
__construct ( array $config = [] ) : void Constructor.
__destruct ( ) : void Destructor. Ensures that the server connection is closed and resources are freed when the adapter instance is destroyed.
calculation ( string $type, mixed $query, array $options = [] ) : integer Executes calculation-related queries, such as those required for count.
conditions ( string $conditions, string $context ) : array Handle conditions.
configureClass ( string $class ) : Returns Configures a model class by setting the primary key to 'id', in keeping with CouchDb conventions.
create ( string $query, array $options = [] ) : boolean Create new document.
delete ( string $query, array $options = [] ) : boolean Delete document.
describe ( string $entity, array $schema = [], array $meta = [] ) : lithium\data\Schema Describe database, create if it does not exist.
enabled ( string $feature = null ) : boolean With no parameter, always returns true, since CouchDB only depends on HTTP. With a parameter, queries for a specific supported feature.
fields ( string $fields, string $context ) : array Fields for query.
item ( string $model, array $data = [], array $options = [] ) : object Returns a newly-created Document object, bound to a model and populated with default data and options.
limit ( string $limit, string $context ) : array Limit for query.
name ( string $name ) : string Quotes identifiers.
order ( string $order, string $context ) : array Order for query.
read ( string $query, array $options = [] ) : object Read from document.
respondsTo ( string $method, boolean $internal = false ) : boolean Determines if a given method can be called.
sources ( object $class = null ) : void Returns an array of object types accessible through this database.
update ( string $query, array $options = [] ) : boolean Update document.

Protected Methods

Method Description
_autoBuild ( string $result ) Helper used for auto building a CouchDB database.
_format ( array $data ) : array Formats a CouchDb result set into a standard result to be passed to item.
_init ( )

Method Details

__call() public method

Magic for passing methods to http service.
public __call ( string $method, array $params = [] ) : mixed
$method string
$params array
return mixed

__construct() public method

Constructor.
public __construct ( array $config = [] ) : void
$config array Available configuration options are: - `'port'` _integer_ - `'version'` _integer_ - `'database'` _string_
return void

__destruct() public method

Destructor. Ensures that the server connection is closed and resources are freed when the adapter instance is destroyed.
public __destruct ( ) : void
return void

_autoBuild() protected method

Helper used for auto building a CouchDB database.
protected _autoBuild ( string $result )
$result string A query result.

_format() protected method

Formats a CouchDb result set into a standard result to be passed to item.
protected _format ( array $data ) : array
$data array data returned from query
return array

_init() protected method

protected _init ( )

calculation() public method

Executes calculation-related queries, such as those required for count.
public calculation ( string $type, mixed $query, array $options = [] ) : integer
$type string Only accepts `count`.
$query mixed The query to be executed.
$options array Optional arguments for the `read()` query that will be executed to obtain the calculation result.
return integer Result of the calculation.

conditions() public method

Handle conditions.
public conditions ( string $conditions, string $context ) : array
$conditions string
$context string
return array

configureClass() public method

Configures a model class by setting the primary key to 'id', in keeping with CouchDb conventions.
See also: lithium\data\Model::$_meta
See also: lithium\data\Model::$_classes
public configureClass ( string $class ) : Returns
$class string The fully-namespaced model class name to be configured.
return Returns an array containing keys `'classes'` and `'meta'`, which will be merged with their respective properties in `Model`.

create() public method

Create new document.
public create ( string $query, array $options = [] ) : boolean
$query string
$options array
return boolean

delete() public method

Delete document.
public delete ( string $query, array $options = [] ) : boolean
$query string
$options array
return boolean

describe() public method

Describe database, create if it does not exist.
public describe ( string $entity, array $schema = [], array $meta = [] ) : lithium\data\Schema
$entity string
$schema array Any schema data pre-defined by the model.
$meta array
return lithium\data\Schema

enabled() public static method

With no parameter, always returns true, since CouchDB only depends on HTTP. With a parameter, queries for a specific supported feature.
public static enabled ( string $feature = null ) : boolean
$feature string Test for support for a specific feature, i.e. `"transactions"` or `"arrays"`.
return boolean Returns `true` if the particular feature support is enabled, otherwise `false`.

fields() public method

Fields for query.
public fields ( string $fields, string $context ) : array
$fields string
$context string
return array

item() public method

Returns a newly-created Document object, bound to a model and populated with default data and options.
public item ( string $model, array $data = [], array $options = [] ) : object
$model string A fully-namespaced class name representing the model class to which the `Document` object will be bound.
$data array The default data with which the new `Document` should be populated.
$options array Any additional options to pass to the `Document`'s constructor
return object Returns a new, un-saved `Document` object bound to the model class specified in `$model`.

limit() public method

Limit for query.
public limit ( string $limit, string $context ) : array
$limit string
$context string
return array

name() public method

CouchDb does not need identifiers quoted, so this method simply returns the identifier.
public name ( string $name ) : string
$name string The identifier to quote.
return string The quoted identifier.

order() public method

Order for query.
public order ( string $order, string $context ) : array
$order string
$context string
return array

read() public method

Read from document.
public read ( string $query, array $options = [] ) : object
$query string
$options array
return object

respondsTo() public method

Determines if a given method can be called.
public respondsTo ( string $method, boolean $internal = false ) : boolean
$method string Name of the method.
$internal boolean Provide `true` to perform check from inside the class/object. When `false` checks also for public visibility; defaults to `false`.
return boolean Returns `true` if the method can be called, `false` otherwise.

sources() public method

Returns an array of object types accessible through this database.
public sources ( object $class = null ) : void
$class object
return void

update() public method

Update document.
public update ( string $query, array $options = [] ) : boolean
$query string
$options array
return boolean

Property Details

$_classes protected_oe property

Classes used by CouchDb.
protected array $_classes
return array

$_db protected_oe property

True if Database exists.
protected bool $_db
return boolean

$_handlers protected_oe property

protected $_handlers

$_iterator protected_oe property

Increment value of current result set loop used by result to handle rows of json responses.
protected string $_iterator
return string