• 时间戳问题


    只管模型的 事

    class Guestinfo extends Model
    {

    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';

    /**
    * 留言板模型
    * @author apolloren
    */

    // 获取器修改时间格式
    public function getcreatetimeAttr($value, $data)
    {
    $value = $value ? $value : (isset($data['refreshtime']) ? $data['create_time'] : '');
    return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }

    public static function guestinfo()
    {

    $list=Guestinfo::order('id desc')->paginate(10);
    return $list;

    }

    public static function add($username,$title,$content)
    {

    $user = new Guestinfo;
    $user->username = $username;
    $user->title = $title;
    $user->content = $content;

    $user->save();
    // 获取自增ID
    echo $user->id;

    }


    }

  • 相关阅读:
    【UNR#3】白鸽
    【POI2011】Garbage
    【NOI2010】海拔
    【HNOI2012】矿场搭建
    【UOJ#177】欧拉回路
    【BZOJ4500】矩阵
    【CF429E】Points and Segments
    【agc001F】Wide Swap
    【BZOJ2138】stone
    【JSOI2009】游戏
  • 原文地址:https://www.cnblogs.com/apolloren/p/12038763.html
Copyright © 2020-2023  润新知