店滴开发者手册店滴开发者手册
首页
指南
插件
接口
智能设备
element后台
SDK
首页
指南
插件
接口
智能设备
element后台
SDK
  • 接口

    • 项目文档
    • /api/api_interface_specification.html
    • 系统安装指南
    • 表单
    • saas
    • 支付
    • 命令行
    • 生成模型类
    • 控制器
    • search
    • 操作单个状态类字段
    • 模型
    • behavior
    • 验证规则
    • 数据库配置指南
    • 字段设计要求
    • /api/db_sharding.html
    • /api/db_read_write_separation.html
    • 检查MySQL服务是否运行
    • 原生sql执行与操作
    • /api/db_transaction.html
    • 关于缓存
    • cookie
    • 用户信息获取
    • /api/event_addonsEvent.html
    • 队列
    • composer 的使用

behavior

数据存储行为

 \common\behaviors\SaveBehavior

行为属性

updatedAttribute

数据最后更新时间

createdAttribute

数据创建时间

time_type

行为时间类型
<?php

namespace addons\diandi_website\models;

use Yii;

class ProductPrice extends \yii\db\ActiveRecord
{
    /**
     * 行为.
     */
    public function behaviors()
    {
        /*自动添加创建和修改时间*/
        return [
            [
                'class' => \common\behaviors\SaveBehavior::className(),
                'updatedAttribute' => 'updated_at',
                'createdAttribute' => 'created_at',
                'time_type' => 'datetime'
            ],
        ];
    }

   
}

Prev
模型
Next
验证规则