Class Phalcon\Mvc\Model\MetaData\Redis

extends abstract class Phalcon\Mvc\Model\MetaData

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

Source on GitHub

Stores model meta-data in the Redis.

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

  1. <?php
  2. use Phalcon\Mvc\Model\Metadata\Redis;
  3. $metaData = new Redis(
  4. [
  5. "host" => "127.0.0.1",
  6. "port" => 6379,
  7. "persistent" => 0,
  8. "statsKey" => "_PHCM_MM",
  9. "lifetime" => 172800,
  10. "index" => 2,
  11. ]
  12. );

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\Redis constructor

public read (mixed $key)

Reads metadata from Redis

public write (mixed $key, mixed $data)

Writes the metadata to Redis

public reset ()

Flush Redis 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

  1. <?php
  2. print_r(
  3. $metaData->readMetaData(
  4. new Robots()
  5. )
  6. );

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

Reads meta-data for certain model

  1. <?php
  2. print_r(
  3. $metaData->readMetaDataIndex(
  4. new Robots(),
  5. 0
  6. )
  7. );

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

  1. <?php
  2. print_r(
  3. $metaData->writeColumnMapIndex(
  4. new Robots(),
  5. MetaData::MODELS_REVERSE_COLUMN_MAP,
  6. [
  7. "leName" => "name",
  8. ]
  9. )
  10. );

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

Reads the ordered/reversed column map for certain model

  1. <?php
  2. print_r(
  3. $metaData->readColumnMap(
  4. new Robots()
  5. )
  6. );

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

  1. <?php
  2. print_r(
  3. $metaData->readColumnMapIndex(
  4. new Robots(),
  5. MetaData::MODELS_REVERSE_COLUMN_MAP
  6. )
  7. );

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

Returns table attributes names (fields)

  1. <?php
  2. print_r(
  3. $metaData->getAttributes(
  4. new Robots()
  5. )
  6. );

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

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

  1. <?php
  2. print_r(
  3. $metaData->getPrimaryKeyAttributes(
  4. new Robots()
  5. )
  6. );

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

  1. <?php
  2. print_r(
  3. $metaData->getNonPrimaryKeyAttributes(
  4. new Robots()
  5. )
  6. );

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

Returns an array of not null attributes

  1. <?php
  2. print_r(
  3. $metaData->getNotNullAttributes(
  4. new Robots()
  5. )
  6. );

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

Returns attributes and their data types

  1. <?php
  2. print_r(
  3. $metaData->getDataTypes(
  4. new Robots()
  5. )
  6. );

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

Returns attributes which types are numerical

  1. <?php
  2. print_r(
  3. $metaData->getDataTypesNumeric(
  4. new Robots()
  5. )
  6. );

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

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

  1. <?php
  2. print_r(
  3. $metaData->getIdentityField(
  4. new Robots()
  5. )
  6. );

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

Returns attributes and their bind data types

  1. <?php
  2. print_r(
  3. $metaData->getBindTypes(
  4. new Robots()
  5. )
  6. );

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

Returns attributes that must be ignored from the INSERT SQL generation

  1. <?php
  2. print_r(
  3. $metaData->getAutomaticCreateAttributes(
  4. new Robots()
  5. )
  6. );

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

Returns attributes that must be ignored from the UPDATE SQL generation

  1. <?php
  2. print_r(
  3. $metaData->getAutomaticUpdateAttributes(
  4. new Robots()
  5. )
  6. );

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

  1. <?php
  2. $metaData->setAutomaticCreateAttributes(
  3. new Robots(),
  4. [
  5. "created_at" => true,
  6. ]
  7. );

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

  1. <?php
  2. $metaData->setAutomaticUpdateAttributes(
  3. new Robots(),
  4. [
  5. "modified_at" => true,
  6. ]
  7. );

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

Set the attributes that allow empty string values

  1. <?php
  2. $metaData->setEmptyStringAttributes(
  3. new Robots(),
  4. [
  5. "name" => true,
  6. ]
  7. );

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

Returns attributes allow empty strings

  1. <?php
  2. print_r(
  3. $metaData->getEmptyStringAttributes(
  4. new Robots()
  5. )
  6. );

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

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

  1. <?php
  2. print_r(
  3. $metaData->getDefaultValues(
  4. new Robots()
  5. )
  6. );

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

Returns the column map if any

  1. <?php
  2. print_r(
  3. $metaData->getColumnMap(
  4. new Robots()
  5. )
  6. );

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

Returns the reverse column map if any

  1. <?php
  2. print_r(
  3. $metaData->getReverseColumnMap(
  4. new Robots()
  5. )
  6. );

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

Check if a model has certain attribute

  1. <?php
  2. var_dump(
  3. $metaData->hasAttribute(
  4. new Robots(),
  5. "name"
  6. )
  7. );

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

Checks if the internal meta-data container is empty

  1. <?php
  2. var_dump(
  3. $metaData->isEmpty()
  4. );