harp-orm/timestamps 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

harp-orm/timestamps

Composer 安装命令:

composer require harp-orm/timestamps

包简介

Automatic createdAt and updatedAt properties

README 文档

README

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version

Automatic createdAt and updatedAt properties

Usage

Add the triats to the Repo and Model classes:

use Harp\Harp\AbstractModel;
use Harp\Timestamps\TimestampsTrait;

class User extends AbstractModel
{
    use TimestampsTrait;

    public static function initialize($config)
    {
        // Adds events to populate the properties
        TimestampsTrait::initialize($config);
    }
}

Database Table:

┌─────────────────────────┐
│ Table: Category         │
├─────────────┬───────────┤
│ id          │ ingeter   │
│ name        │ string    │
│ createdAt*  │ timestamp │
│ updatedAt*  │ timestamp │
└─────────────┴───────────┘
* Required fields

Interface

echo $user->createdAt; // 2014-01-01 00:00:00
echo $user->updatedAt; // 2014-01-01 00:00:00

echo $user->getCreatedAt(); // DateTime object
$user->setCreatedAt(new DateTime());

echo $user->getUpdatedAt(); // DateTime object
$user->setUpdatedAt(new DateTime());

Testing

You can set the "current date" that the the trait uses with the "TimestampsTrait::setCurrentDate($date)" method.

TimestampsTrait::setCurrentDate('2014-03-01 10:00:00');

$user = new User();

echo $user->createdAt; // 2014-03-01 10:00:00
echo $user->updatedAt; // 2014-03-01 10:00:00

License

Copyright (c) 2014, Clippings Ltd. Developed by Ivan Kerin

Under BSD-3-Clause license, read LICENSE file.

统计信息

  • 总下载量: 132
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2014-06-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固