Table Of Contents

Previous topic

< Abstract class Phalcon\Mvc\Model\MetaData

Next topic

Class Phalcon\Mvc\Model\MetaData\Files >

Class Phalcon\Mvc\Model\MetaData\Apc

extends abstract class Phalcon\Mvc\Model\MetaData

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

Stores model meta-data in the APC cache. Data will erased if the web server is restarted By default meta-data is stored for 48 hours (172800 seconds) You can query the meta-data by printing apc_fetch(‘$PMM$’) or apc_fetch(‘$PMM$my-app-id’)

<?php

$metaData = new Phalcon\Mvc\Model\Metadata\Apc(array(
    'prefix' => 'my-app-id',
    'lifetime' => 86400
));

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_COLUMN_MAP

integer MODELS_REVERSE_COLUMN_MAP

Methods

public __construct ([array $options])

Phalcon\Mvc\Model\MetaData\Apc constructor

public array read (string $key)

Reads meta-data from APC

public write (string $key, array $data)

Writes the meta-data to APC

public reset ()

...

protected _initialize () 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 Phalcon\DiInterface getDI () inherited from Phalcon\Mvc\Model\MetaData

Returns the DependencyInjector container

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

Set the meta-data extraction strategy

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

Return the strategy to obtain the meta-data

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

Reads the complete meta-data for certain model

<?php

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

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

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

<?php

print_r($metaData->writeColumnMapIndex(new Robots(), MetaData::MODELS_REVERSE_COLUMN_MAP, array('leName' => 'name')));

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

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

<?php

print_r($metaData->writeColumnMapIndex(new Robots(), MetaData::MODELS_REVERSE_COLUMN_MAP, array('leName' => 'name')));

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

Reads the ordered/reversed column map for certain model

<?php

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

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

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

<?php

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

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

Returns table attributes names (fields)

<?php

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

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

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

<?php

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

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

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

<?php

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

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

Returns an array of not null attributes

<?php

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

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

Returns attributes and their data types

<?php

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

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

Returns attributes which types are numerical

<?php

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)

<?php

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

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

Returns attributes and their bind data types

<?php

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

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

Returns attributes that must be ignored from the INSERT SQL generation

<?php

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

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

Returns attributes that must be ignored from the UPDATE SQL generation

<?php

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

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

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

<?php

$metaData->setAutomaticCreateAttributes(new Robots(), array('created_at' => true));

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

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

<?php

$metaData->setAutomaticUpdateAttributes(new Robots(), array('modified_at' => true));

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

Returns the column map if any

<?php

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

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

Returns the reverse column map if any

<?php

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

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

Check if a model has certain attribute

<?php

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

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

Checks if the internal meta-data container is empty

<?php

var_dump($metaData->isEmpty());