📜  Phalcon模型

📅  最后修改于: 2021-01-07 09:28:13             🧑  作者: Mango

Phalcon模型

模型由应用程序的信息或数据组成。它通过管理规则来操纵数据。在目录Phalcon \ Mvc \ Model下可以找到该目录,所有基本应用程序均保持相同。

它提供以下服务:

  • 数据库独立性
  • CRUD功能
  • 先进的查找功能
  • 关联模型的能力

以下是一些可以启用/禁用特定功能的功能的列表:

Option Description Default
astCache Enables/Disables callbacks, hooks and event notifications from all the models. null
cacheLevel 3
castOnHydrate false
columnRenaming Enables/Disables the column renaming. true
disableAssignSetters Allow disabling setters in your model. false
enableImplicitJoins true
enableLiterals true
events Enables/Disables callbacks, hooks and event notifications from all the models. true
exceptionOnFailedSave Enables/Disables throwing an exception when there is a failed save(). false
lateStateBinding Enables/Disables late state binding of the Phalcon\Mvc\Model::cloneResultMap()method. false
notNullValidations The ORM automatically validate the not null columns present in the mapped table true
parserCache null
phqlLiterals Enables/Disables literals in the PHQL parser true
uniqueCacheId 3
updateSnapshotOnSave Enables/Disables updating snapshots on save(). true

创建模型

Model是扩展Phalcon \ Mvc \ Model的类。在创建模型时,使用了initialize()方法,该方法在请求期间仅被调用一次。

setSource(car_price');
    }
}
?>

但是,如果要对每个实例执行初始化任务,则可以使用onConstruct()方法。