CakePHP - 在模型中设置默认字段值 [英] CakePHP - Set Default Field Values in the Model

查看:153
本文介绍了CakePHP - 在模型中设置默认字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为模型中的字段设置默认值?

How do you set a default value for a field in a model?

编辑:

已尝试使用_schema的建议方法,但不使用默认值。

I have tried the method using _schema as suggested, but the default value is not being used.

public $_schema = array(
    'newsletter' => array(
        'default' => 1
    ),
);  


推荐答案

数据库?我真的不明白为什么你会想做CakePHP一边...

It would be better to set the default value in the database? I don't really see why you would want to do it CakePHP side...

这篇关于CakePHP - 在模型中设置默认字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆