🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# Class **Phalcon\Mvc\Model\MetaData\Session**[](# "永久链接至标题") *extends* abstract class [*Phalcon\Mvc\Model\MetaData*](#) *implements*`Phalcon\Di\InjectionAwareInterface`, [*Phalcon\Mvc\Model\MetaDataInterface*](#) Stores model meta-data in session. Data will erased when the session finishes. Meta-data are permanent while the session is active. You can query the meta-data by printing $_SESSION[‘$PMM$'] ~~~ <?php $metaData = new \Phalcon\Mvc\Model\Metadata\Session(array( 'prefix' => 'my-app-id' )); ~~~ ### 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\Session constructor public *array***read** (*string* $key) Reads meta-data from $_SESSION public **write** (*string* $key, *array* $data) Writes the meta-data to $_SESSION final protected **_initialize** (*unknown* $model, *unknown* $key, *unknown* $table, *unknown* $schema) inherited from Phalcon\Mvc\Model\MetaData Initialize the metadata for certain table public **setDI** (*unknown* $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** (*unknown* $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** (*unknown* $model) inherited from Phalcon\Mvc\Model\MetaData Reads the complete meta-data for certain model ~~~ <?php print_r($metaData->readMetaData(new Robots()); ~~~ final public **readMetaDataIndex** (*unknown* $model, *unknown* $index) inherited from Phalcon\Mvc\Model\MetaData Reads meta-data for certain model ~~~ <?php print_r($metaData->readMetaDataIndex(new Robots(), 0); ~~~ final public **writeMetaDataIndex** (*unknown* $model, *unknown* $index, *unknown* $data) 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'))); ~~~ final public **readColumnMap** (*unknown* $model) inherited from Phalcon\Mvc\Model\MetaData Reads the ordered/reversed column map for certain model ~~~ <?php print_r($metaData->readColumnMap(new Robots())); ~~~ final public **readColumnMapIndex** (*unknown* $model, *unknown* $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 **getAttributes** (*unknown* $model) inherited from Phalcon\Mvc\Model\MetaData Returns table attributes names (fields) ~~~ <?php print_r($metaData->getAttributes(new Robots())); ~~~ public **getPrimaryKeyAttributes** (*unknown* $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 **getNonPrimaryKeyAttributes** (*unknown* $model) inherited from Phalcon\Mvc\Model\MetaData Returns an array of fields which are not part of the primary key ~~~ <?php print_r($metaData->getNonPrimaryKeyAttributes(new Robots())); ~~~ public **getNotNullAttributes** (*unknown* $model) inherited from Phalcon\Mvc\Model\MetaData Returns an array of not null attributes ~~~ <?php print_r($metaData->getNotNullAttributes(new Robots())); ~~~ public **getDataTypes** (*unknown* $model) inherited from Phalcon\Mvc\Model\MetaData Returns attributes and their data types ~~~ <?php print_r($metaData->getDataTypes(new Robots())); ~~~ public **getDataTypesNumeric** (*unknown* $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 **getBindTypes** (*unknown* $model) inherited from Phalcon\Mvc\Model\MetaData Returns attributes and their bind data types ~~~ <?php print_r($metaData->getBindTypes(new Robots())); ~~~ public **getAutomaticCreateAttributes** (*unknown* $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 **getAutomaticUpdateAttributes** (*unknown* $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** (*unknown* $model, *unknown* $attributes) 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** (*unknown* $model, *unknown* $attributes) 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 **setEmptyStringAttributes** (*unknown* $model, *unknown* $attributes) inherited from Phalcon\Mvc\Model\MetaData Set the attributes that allow empty string values ~~~ <?php $metaData->setEmptyStringAttributes(new Robots(), array('name' => true)); ~~~ public **getEmptyStringAttributes** (*unknown* $model) inherited from Phalcon\Mvc\Model\MetaData Returns attributes allow empty strings ~~~ <?php print_r($metaData->getEmptyStringAttributes(new Robots())); ~~~ public **getDefaultValues** (*unknown* $model) inherited from Phalcon\Mvc\Model\MetaData Returns attributes (which have default values) and their default values ~~~ <?php print_r($metaData->getDefaultValues(new Robots())); ~~~ public **getColumnMap** (*unknown* $model) inherited from Phalcon\Mvc\Model\MetaData Returns the column map if any ~~~ <?php print_r($metaData->getColumnMap(new Robots())); ~~~ public **getReverseColumnMap** (*unknown* $model) inherited from Phalcon\Mvc\Model\MetaData Returns the reverse column map if any ~~~ <?php print_r($metaData->getReverseColumnMap(new Robots())); ~~~ public **hasAttribute** (*unknown* $model, *unknown* $attribute) inherited from Phalcon\Mvc\Model\MetaData Check if a model has certain attribute ~~~ <?php var_dump($metaData->hasAttribute(new Robots(), 'name')); ~~~ public **isEmpty** () inherited from Phalcon\Mvc\Model\MetaData Checks if the internal meta-data container is empty ~~~ <?php var_dump($metaData->isEmpty()); ~~~ public **reset** () inherited from Phalcon\Mvc\Model\MetaData Resets internal meta-data in order to regenerate it ~~~ <?php $metaData->reset(); ~~~ | - [索引](# "总目录") - [下一页](# "Class Phalcon\Mvc\Model\MetaData\Strategy\Annotations") | - [上一页](# "Class Phalcon\Mvc\Model\MetaData\Memory") | - [API Indice](#) »