ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# Class Phalcon\\Mvc\\Model\\Message # Class **Phalcon\\Mvc\\Model\\Message** *implements*[*Phalcon\\Mvc\\Model\\MessageInterface*](#) Encapsulates validation info generated before save/delete records fails ``` <pre class="calibre14">``` <?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](#) »