PHP 클래스 lithium\data\Source

In addition to utility methods and standardized properties, it defines the implementation tasks for all Lithium classes that work with external data, such as connections to remote resources (connect() and disconnect()), introspecting available data objects (entities() and describe()), and a standard read/write interface (create(), read(), update() and delete()). Subclasses may implement any other non-standard functionality, but the above methods define the requirements for interacting with Model objects, and other classes within lithium\data.
상속: extends lithium\core\Object
파일 보기 프로젝트 열기: unionofrad/lithium 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$connection mixed Stores a connection to a remote resource. Usually a database connection (resource type), or an HTTP connection object ('object' type).

보호된 프로퍼티들

프로퍼티 타입 설명
$_autoConfig array The list of object properties to be automatically assigned from configuration passed to __construct().
$_cachedMethods array Holds cached methods.
$_classes array Default entity and set classes used by subclasses of Source.
$_isConnected boolean Stores the status of this object's connection. Updated when connect() or disconnect() are called, or if an error occurs that closes the object's connection.

공개 메소드들

메소드 설명
__construct ( array $config = [] ) : void Constructor.
__destruct ( ) : void Destructor. Ensures the connection is closed, before the object is destroyed.
applyStrategy ( array $options, object $context ) Applying a strategy to a lithium\data\model\Query object
configureClass ( string $class ) : array A method which can be optionally implemented to configure a model class.
connect ( ) Abstract. Must be defined by child classes.
create ( mixed $query, array $options = [] ) : boolean Create a record. This is the abstract method that is implemented by specific data sources.
delete ( mixed $query, array $options = [] ) : boolean Abstract. Must be defined by child classes.
describe ( mixed $entity, array $schema = [], array $meta = [] ) : array Gets the column schema for a given entity (such as a database table).
disconnect ( ) Abstract. Must be defined by child classes.
enabled ( string $feature = null ) : boolean With no parameter, checks a specific supported feature.
isConnected ( array $options = [] ) : boolean Checks the connection status of this data source. If the 'autoConnect' option is set to true and the source connection is not currently active, a connection attempt will be made before returning the result of the connection status.
methods ( ) : array Returns the list of methods which format values imported from Query objects. Should be overridden in subclasses.
name ( string $name ) : string Quotes data-source-native identifiers, where applicable.
read ( mixed $query, array $options = [] ) : boolean Abstract. Must be defined by child classes.
relationFieldName ( $type, $name ) : string Returns the field name of a relation name (underscore).
relationship ( $class, $type, $name, array $options = [] ) : array Defines or modifies the default settings of a relationship between two models.
sources ( string $class = null ) : array Returns a list of objects (sources) that models can bind to, i.e. a list of tables in the case of a database, or REST collections, in the case of a web service.
update ( mixed $query, array $options = [] ) : boolean Updates a set of records in a concrete data store.

보호된 메소드들

메소드 설명
_init ( )

메소드 상세

__construct() 공개 메소드

Constructor.
public __construct ( array $config = [] ) : void
$config array Available options are: - `'autoConnect'` _boolean_: If `true`, a connection is made on initialization. Defaults to `true`.
리턴 void

__destruct() 공개 메소드

Destructor. Ensures the connection is closed, before the object is destroyed.
public __destruct ( ) : void
리턴 void

_init() 보호된 메소드

protected _init ( )

applyStrategy() 공개 메소드

Applying a strategy to a lithium\data\model\Query object
public applyStrategy ( array $options, object $context )
$options array The option array
$context object A query object to configure

configureClass() 공개 메소드

A method which can be optionally implemented to configure a model class.
또한 보기: lithium\data\Model::$_meta
또한 보기: lithium\data\Model::$_finders
또한 보기: lithium\data\Model::$_classes
public configureClass ( string $class ) : array
$class string The name of the model class to be configured.
리턴 array This method should return an array one or more of the following keys: `'meta'`, `'classes'` or `'finders'`. These keys maps to the three corresponding properties in `lithium\data\Model`, and are used to override the base-level default settings and dependencies.

connect() 추상적인 공개 메소드

Abstract. Must be defined by child classes.
abstract public connect ( )

create() 추상적인 공개 메소드

This method should take a query object and use it to create a record in the data source.
abstract public create ( mixed $query, array $options = [] ) : boolean
$query mixed An object which defines the update operation(s) that should be performed against the data store. This can be a `Query`, a `RecordSet`, a `Record`, or a subclass of one of the three. Alternatively, `$query` can be an adapter-specific query string.
$options array The options from Model include, - `validate` _boolean_ default: true - `events` _string_ default: create - `whitelist` _array_ default: null - `callbacks` _boolean_ default: true - `locked` _boolean_ default: true
리턴 boolean Returns true if the operation was a success, otherwise false.

delete() 추상적인 공개 메소드

Abstract. Must be defined by child classes.
abstract public delete ( mixed $query, array $options = [] ) : boolean
$query mixed
$options array
리턴 boolean Returns true if the operation was a success, otherwise false.

describe() 추상적인 공개 메소드

Gets the column schema for a given entity (such as a database table).
abstract public describe ( mixed $entity, array $schema = [], array $meta = [] ) : array
$entity mixed Specifies the table name for which the schema should be returned, or the class name of the model object requesting the schema, in which case the model class will be queried for the correct table name.
$schema array
$meta array The meta-information for the model class, which this method may use in introspecting the schema.
리턴 array Returns a `Schema` object describing the given model's schema, where the array keys are the available fields, and the values are arrays describing each field, containing the following keys: - `'type'`: The field type name

disconnect() 추상적인 공개 메소드

Abstract. Must be defined by child classes.
abstract public disconnect ( )

enabled() 공개 정적인 메소드

With no parameter, checks 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"`.
리턴 boolean Returns `true` if the particular feature (or if MongoDB) support is enabled, otherwise `false`.

isConnected() 공개 메소드

Checks the connection status of this data source. If the 'autoConnect' option is set to true and the source connection is not currently active, a connection attempt will be made before returning the result of the connection status.
public isConnected ( array $options = [] ) : boolean
$options array The options available for this method: - 'autoConnect': If true, and the connection is not currently active, calls `connect()` on this object. Defaults to `false`.
리턴 boolean Returns the current value of `$_isConnected`, indicating whether or not the object's connection is currently active. This value may not always be accurate, as the connection could have timed out or otherwise been dropped by the remote resource during the course of the request.

methods() 공개 메소드

Returns the list of methods which format values imported from Query objects. Should be overridden in subclasses.
또한 보기: lithium\data\model\Query
public methods ( ) : array
리턴 array

name() 공개 메소드

Quotes data-source-native identifiers, where applicable.
public name ( string $name ) : string
$name string Identifier name.
리턴 string Returns `$name`, quoted if applicable.

read() 추상적인 공개 메소드

Abstract. Must be defined by child classes.
abstract public read ( mixed $query, array $options = [] ) : boolean
$query mixed
$options array
리턴 boolean Returns true if the operation was a success, otherwise false.

relationFieldName() 공개 메소드

Returns the field name of a relation name (underscore).
public relationFieldName ( $type, $name ) : string
리턴 string

relationship() 추상적인 공개 메소드

Defines or modifies the default settings of a relationship between two models.
abstract public relationship ( $class, $type, $name, array $options = [] ) : array
$class the primary model of the relationship
$type the type of the relationship (hasMany, hasOne, belongsTo)
$name the name of the relationship
$options array relationship options
리턴 array Returns an array containing the configuration for a model relationship.

sources() 추상적인 공개 메소드

Returns a list of objects (sources) that models can bind to, i.e. a list of tables in the case of a database, or REST collections, in the case of a web service.
abstract public sources ( string $class = null ) : array
$class string The fully-name-spaced class name of the object making the request.
리턴 array Returns an array of objects to which models can connect.

update() 추상적인 공개 메소드

Updates a set of records in a concrete data store.
abstract public update ( mixed $query, array $options = [] ) : boolean
$query mixed An object which defines the update operation(s) that should be performed against the data store. This can be a `Query`, a `RecordSet`, a `Record`, or a subclass of one of the three. Alternatively, `$query` can be an adapter-specific query string.
$options array Options to execute, which are defined by the concrete implementation.
리턴 boolean Returns true if the update operation was a success, otherwise false.

프로퍼티 상세

$_autoConfig 보호되어 있는 프로퍼티

The list of object properties to be automatically assigned from configuration passed to __construct().
protected array $_autoConfig
리턴 array

$_cachedMethods 보호되어 있는 프로퍼티

Holds cached methods.
또한 보기: lithium\data\Source::methods()
protected array $_cachedMethods
리턴 array

$_classes 보호되어 있는 프로퍼티

Default entity and set classes used by subclasses of Source.
protected array $_classes
리턴 array

$_isConnected 보호되어 있는 프로퍼티

Stores the status of this object's connection. Updated when connect() or disconnect() are called, or if an error occurs that closes the object's connection.
protected bool $_isConnected
리턴 boolean

$connection 공개적으로 프로퍼티

Stores a connection to a remote resource. Usually a database connection (resource type), or an HTTP connection object ('object' type).
public mixed $connection
리턴 mixed