extends abstract class Phalcon\Mvc\Model\MetaData
implements Phalcon\Mvc\Model\MetaDataInterface, Phalcon\Di\InjectionAwareInterface
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$’]
$metaData = new \Phalcon\Mvc\Model\Metadata\Session(
[
"prefix" => "my-app-id",
]
);
Phalcon\Mvc\Model\MetaData\Session constructor
Reads meta-data from $_SESSION
Writes the meta-data to $_SESSION
Initialize the metadata for certain table
Sets the DependencyInjector container
Returns the DependencyInjector container
Set the meta-data extraction strategy
Return the strategy to obtain the meta-data
Reads the complete meta-data for certain model
print_r(
$metaData->readMetaData(
new Robots()
)
);
Reads meta-data for certain model
print_r(
$metaData->readMetaDataIndex(
new Robots(),
0
)
);
Writes meta-data for certain model using a MODEL_* constant
print_r(
$metaData->writeColumnMapIndex(
new Robots(),
MetaData::MODELS_REVERSE_COLUMN_MAP,
[
"leName" => "name",
]
)
);
Reads the ordered/reversed column map for certain model
print_r(
$metaData->readColumnMap(
new Robots()
)
);
Reads column-map information for certain model using a MODEL_* constant
print_r(
$metaData->readColumnMapIndex(
new Robots(),
MetaData::MODELS_REVERSE_COLUMN_MAP
)
);
Returns table attributes names (fields)
print_r(
$metaData->getAttributes(
new Robots()
)
);
Returns an array of fields which are part of the primary key
print_r(
$metaData->getPrimaryKeyAttributes(
new Robots()
)
);
Returns an array of fields which are not part of the primary key
print_r(
$metaData->getNonPrimaryKeyAttributes(
new Robots()
)
);
Returns an array of not null attributes
print_r(
$metaData->getNotNullAttributes(
new Robots()
)
);
Returns attributes and their data types
print_r(
$metaData->getDataTypes(
new Robots()
)
);
Returns attributes which types are numerical
print_r(
$metaData->getDataTypesNumeric(
new Robots()
)
);
Returns the name of identity field (if one is present)
print_r(
$metaData->getIdentityField(
new Robots()
)
);
Returns attributes and their bind data types
print_r(
$metaData->getBindTypes(
new Robots()
)
);
Returns attributes that must be ignored from the INSERT SQL generation
print_r(
$metaData->getAutomaticCreateAttributes(
new Robots()
)
);
Returns attributes that must be ignored from the UPDATE SQL generation
print_r(
$metaData->getAutomaticUpdateAttributes(
new Robots()
)
);
Set the attributes that must be ignored from the INSERT SQL generation
$metaData->setAutomaticCreateAttributes(
new Robots(),
[
"created_at" => true,
]
);
Set the attributes that must be ignored from the UPDATE SQL generation
$metaData->setAutomaticUpdateAttributes(
new Robots(),
[
"modified_at" => true,
]
);
Set the attributes that allow empty string values
$metaData->setEmptyStringAttributes(
new Robots(),
[
"name" => true,
]
);
Returns attributes allow empty strings
print_r(
$metaData->getEmptyStringAttributes(
new Robots()
)
);
Returns attributes (which have default values) and their default values
print_r(
$metaData->getDefaultValues(
new Robots()
)
);
Returns the column map if any
print_r(
$metaData->getColumnMap(
new Robots()
)
);
Returns the reverse column map if any
print_r(
$metaData->getReverseColumnMap(
new Robots()
)
);
Check if a model has certain attribute
var_dump(
$metaData->hasAttribute(
new Robots(),
"name"
)
);
Checks if the internal meta-data container is empty
var_dump(
$metaData->isEmpty()
);
Resets internal meta-data in order to regenerate it
$metaData->reset();
© 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_Session.html