This is the model class
class Mails extends \Phalcon\Mvc\Model {
public static function newMail($sender, $receiver, $type, $content = '') {
$mail = new Mails ();
$mail->src_id = $sender;
$mail->dst_id = $receiver;
$mail->type = $type;
$mail->content=$content,
$mail->when=time();
$mail->status='unread';
$mail->save();
}
}
table definition:
CREATE TABLE `mails` (
`email_id` int(12) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`src_id` int(22) NOT NULL COMMENT '发送者',
`dst_id` int(22) NOT NULL COMMENT '接收者',
`type` enum('other','request','gift','text') NOT NULL DEFAULT 'text' COMMENT '类型',
`content` varchar(512) NOT NULL DEFAULT '' COMMENT '内容',
`when` int(12) NOT NULL DEFAULT '0' COMMENT '发送时间戳',
`status` enum('none','deleted','accepted','read','unread') NOT NULL DEFAULT 'none' COMMENT '状态',
PRIMARY KEY (`email_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
when I call:
Mails::newMail('123','321','text');
I got a 'content is required' but in debug windows, $content is an empty string , NOT a NULL.