💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# Class **Phalcon\Mvc\Model\Message**[](# "永久链接至标题") *implements*[*Phalcon\Mvc\Model\MessageInterface*](#) Encapsulates validation info generated before save/delete records fails ~~~ <?php use Phalcon\Mvc\Model\Message as Message; class Robots extends \Phalcon\Mvc\Model { public function beforeSave() { if (this->name == 'Peter') { text = "A robot cannot be named Peter"; field = "name"; type = "InvalidValue"; message = new Message(text, field, type); this->appendMessage(message); } } } ~~~ ### Methods[](# "永久链接至标题") public **__construct** (*string* $message, [*string|array* $field], [*string* $type], [[*Phalcon\Mvc\ModelInterface*](#) $model]) Phalcon\Mvc\Model\Message constructor public **setType** (*unknown* $type) Sets message type public **getType** () Returns message type public **setMessage** (*unknown* $message) Sets verbose message public **getMessage** () Returns verbose message public **setField** (*unknown* $field) Sets field name related to message public **getField** () Returns field name related to message public **setModel** (*unknown* $model) Set the model who generates the message public **getModel** () Returns the model that produced the message public **__toString** () Magic __toString method returns verbose message public static **__set_state** (*unknown* $message) Magic __set_state helps to re-build messages variable exporting | - [索引](# "总目录") - [下一页](# "Abstract class Phalcon\Mvc\Model\MetaData") | - [上一页](# "Class Phalcon\Mvc\Model\Manager") | - [API Indice](#) »