W3cubDocs

/Phalcon 3

Class Phalcon\Mvc\Model\MetaData\Libmemcached

extends abstract class Phalcon\Mvc\Model\MetaData

implements Phalcon\Mvc\Model\MetaDataInterface, Phalcon\Di\InjectionAwareInterface

Source on GitHub

Stores model meta-data in the Memcache.

By default meta-data is stored for 48 hours (172800 seconds)

$metaData = new Phalcon\Mvc\Model\Metadata\Libmemcached(
    [
        "servers" => [
            [
                "host"   => "localhost",
                "port"   => 11211,
                "weight" => 1,
            ],
        ],
        "client" => [
            Memcached::OPT_HASH       => Memcached::HASH_MD5,
            Memcached::OPT_PREFIX_KEY => "prefix.",
        ],
        "lifetime" => 3600,
        "prefix"   => "my_",
    ]
);

Constants

integer MODELS_ATTRIBUTES

integer MODELS_PRIMARY_KEY

integer MODELS_NON_PRIMARY_KEY

integer MODELS_NOT_NULL

integer MODELS_DATA_TYPES

integer MODELS_DATA_TYPES_NUMERIC

integer MODELS_DATE_AT

integer MODELS_DATE_IN

integer MODELS_IDENTITY_COLUMN

integer MODELS_DATA_TYPES_BIND

integer MODELS_AUTOMATIC_DEFAULT_INSERT

integer MODELS_AUTOMATIC_DEFAULT_UPDATE

integer MODELS_DEFAULT_VALUES

integer MODELS_EMPTY_STRING_VALUES

integer MODELS_COLUMN_MAP

integer MODELS_REVERSE_COLUMN_MAP

Methods

public __construct ([array $options])

Phalcon\Mvc\Model\MetaData\Libmemcached constructor

public read (mixed $key)

Reads metadata from Memcache

public write (mixed $key, mixed $data)

Writes the metadata to Memcache

public reset ()

Flush Memcache data and resets internal meta-data in order to regenerate it

final protected _initialize (Phalcon\Mvc\ModelInterface $model, mixed $key, mixed $table, mixed $schema) inherited from Phalcon\Mvc\Model\MetaData

Initialize the metadata for certain table

public setDI (Phalcon\DiInterface $dependencyInjector) inherited from Phalcon\Mvc\Model\MetaData

Sets the DependencyInjector container

public getDI () inherited from Phalcon\Mvc\Model\MetaData

Returns the DependencyInjector container

public setStrategy (Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy) inherited from Phalcon\Mvc\Model\MetaData

Set the meta-data extraction strategy

public getStrategy () inherited from Phalcon\Mvc\Model\MetaData

Return the strategy to obtain the meta-data

final public readMetaData (Phalcon\Mvc\ModelInterface $model) inherited from Phalcon\Mvc\Model\MetaData

Reads the complete meta-data for certain model

print_r(
    $metaData->readMetaData(
        new Robots()
    )
);

final public readMetaDataIndex (Phalcon\Mvc\ModelInterface $model, mixed $index) inherited from Phalcon\Mvc\Model\MetaData

Reads meta-data for certain model

print_r(
    $metaData->readMetaDataIndex(
        new Robots(),
        0
    )
);

final public writeMetaDataIndex (Phalcon\Mvc\ModelInterface $model, mixed $index, mixed $data) inherited from Phalcon\Mvc\Model\MetaData

Writes meta-data for certain model using a MODEL_* constant

print_r(
    $metaData->writeColumnMapIndex(
        new Robots(),
        MetaData::MODELS_REVERSE_COLUMN_MAP,
        [
            "leName" => "name",
        ]
    )
);

final public readColumnMap (Phalcon\Mvc\ModelInterface $model) inherited from Phalcon\Mvc\Model\MetaData

Reads the ordered/reversed column map for certain model

print_r(
    $metaData->readColumnMap(
        new Robots()
    )
);

final public readColumnMapIndex (Phalcon\Mvc\ModelInterface $model, mixed $index) inherited from Phalcon\Mvc\Model\MetaData

Reads column-map information for certain model using a MODEL_* constant

print_r(
    $metaData->readColumnMapIndex(
        new Robots(),
        MetaData::MODELS_REVERSE_COLUMN_MAP
    )
);

public getAttributes (Phalcon\Mvc\ModelInterface $model) inherited from Phalcon\Mvc\Model\MetaData

Returns table attributes names (fields)

print_r(
    $metaData->getAttributes(
        new Robots()
    )
);

public getPrimaryKeyAttributes (Phalcon\Mvc\ModelInterface $model) inherited from Phalcon\Mvc\Model\MetaData

Returns an array of fields which are part of the primary key

print_r(
    $metaData->getPrimaryKeyAttributes(
        new Robots()
    )
);

public getNonPrimaryKeyAttributes (Phalcon\Mvc\ModelInterface $model) inherited from Phalcon\Mvc\Model\MetaData

Returns an array of fields which are not part of the primary key

print_r(
    $metaData->getNonPrimaryKeyAttributes(
        new Robots()
    )
);

public getNotNullAttributes (Phalcon\Mvc\ModelInterface $model) inherited from Phalcon\Mvc\Model\MetaData

Returns an array of not null attributes

print_r(
    $metaData->getNotNullAttributes(
        new Robots()
    )
);

public getDataTypes (Phalcon\Mvc\ModelInterface $model) inherited from Phalcon\Mvc\Model\MetaData

Returns attributes and their data types

print_r(
    $metaData->getDataTypes(
        new Robots()
    )
);

public getDataTypesNumeric (Phalcon\Mvc\ModelInterface $model) inherited from Phalcon\Mvc\Model\MetaData

Returns attributes which types are numerical

print_r(
    $metaData->getDataTypesNumeric(
        new Robots()
    )
);

public string getIdentityField (Phalcon\Mvc\ModelInterface $model) inherited from Phalcon\Mvc\Model\MetaData

Returns the name of identity field (if one is present)

print_r(
    $metaData->getIdentityField(
        new Robots()
    )
);

public getBindTypes (Phalcon\Mvc\ModelInterface $model) inherited from Phalcon\Mvc\Model\MetaData

Returns attributes and their bind data types

print_r(
    $metaData->getBindTypes(
        new Robots()
    )
);

public getAutomaticCreateAttributes (Phalcon\Mvc\ModelInterface $model) inherited from Phalcon\Mvc\Model\MetaData

Returns attributes that must be ignored from the INSERT SQL generation

print_r(
    $metaData->getAutomaticCreateAttributes(
        new Robots()
    )
);

public getAutomaticUpdateAttributes (Phalcon\Mvc\ModelInterface $model) inherited from Phalcon\Mvc\Model\MetaData

Returns attributes that must be ignored from the UPDATE SQL generation

print_r(
    $metaData->getAutomaticUpdateAttributes(
        new Robots()
    )
);

public setAutomaticCreateAttributes (Phalcon\Mvc\ModelInterface $model, array $attributes) inherited from Phalcon\Mvc\Model\MetaData

Set the attributes that must be ignored from the INSERT SQL generation

$metaData->setAutomaticCreateAttributes(
    new Robots(),
    [
        "created_at" => true,
    ]
);

public setAutomaticUpdateAttributes (Phalcon\Mvc\ModelInterface $model, array $attributes) inherited from Phalcon\Mvc\Model\MetaData

Set the attributes that must be ignored from the UPDATE SQL generation

$metaData->setAutomaticUpdateAttributes(
    new Robots(),
    [
        "modified_at" => true,
    ]
);

public setEmptyStringAttributes (Phalcon\Mvc\ModelInterface $model, array $attributes) inherited from Phalcon\Mvc\Model\MetaData

Set the attributes that allow empty string values

$metaData->setEmptyStringAttributes(
    new Robots(),
    [
        "name" => true,
    ]
);

public getEmptyStringAttributes (Phalcon\Mvc\ModelInterface $model) inherited from Phalcon\Mvc\Model\MetaData

Returns attributes allow empty strings

print_r(
    $metaData->getEmptyStringAttributes(
        new Robots()
    )
);

public getDefaultValues (Phalcon\Mvc\ModelInterface $model) inherited from Phalcon\Mvc\Model\MetaData

Returns attributes (which have default values) and their default values

print_r(
    $metaData->getDefaultValues(
        new Robots()
    )
);

public getColumnMap (Phalcon\Mvc\ModelInterface $model) inherited from Phalcon\Mvc\Model\MetaData

Returns the column map if any

print_r(
    $metaData->getColumnMap(
        new Robots()
    )
);

public getReverseColumnMap (Phalcon\Mvc\ModelInterface $model) inherited from Phalcon\Mvc\Model\MetaData

Returns the reverse column map if any

print_r(
    $metaData->getReverseColumnMap(
        new Robots()
    )
);

public hasAttribute (Phalcon\Mvc\ModelInterface $model, mixed $attribute) inherited from Phalcon\Mvc\Model\MetaData

Check if a model has certain attribute

var_dump(
    $metaData->hasAttribute(
        new Robots(),
        "name"
    )
);

public isEmpty () inherited from Phalcon\Mvc\Model\MetaData

Checks if the internal meta-data container is empty

var_dump(
    $metaData->isEmpty()
);

© 2011–2017 Phalcon Framework Team
Licensed under the Creative Commons Attribution License 3.0.
https://docs.phalconphp.com/en/latest/api/Phalcon_Mvc_Model_MetaData_Libmemcached.html