jamband/yii2-ensure-unique-behavior 问题修复 & 功能扩展

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

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

jamband/yii2-ensure-unique-behavior

最新稳定版本:v0.6.0

Composer 安装命令:

composer require jamband/yii2-ensure-unique-behavior

包简介

This extension insert unique identifier automatically for the Yii 2 framework

README 文档

README

Build Status Latest Stable Version Total Downloads

Insert unique identifier automatically for the Yii 2 framework.

Requirements

  • PHP 7.4 or later
  • Yii 2.x

Installation

composer require jamband/yii2-ensure-unique-behavior

Examples

Creates a post table:

CREATE TABLE `post` (
    `id` CHAR(11) COLLATE utf8_bin NOT NULL,
    `title` VARCHAR(255) NOT NULL,
    `content` TEXT NOT NULL,
    `created_at` INT(11) NOT NULL,
    `updated_at` INT(11) NOT NULL,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB CHARACTER SET=utf8 COLLATE=utf8_unicode_ci;

Settings EnsureUniqueBehavior in Model:

namespace app\models;

use jamband\behaviors\EnsureUniqueBehavior;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;

class Post extends ActiveRecord
{
    public function behaviors()
    {
        return [
            TimestampBehavior::class,
            [
                'class' => EnsureUniqueBehavior::class,
                'attribute' => 'id', // default
                'length' => 11, // default
            ],
        ];
    }
}

And saves a new model:

$model = new \app\models\Post();
$model->title = 'title';
$model->content = 'content';
$model->save();

// This value is eusure uniqueness
var_dump($model->id); // string(11) "-ZRLSS-4vl_"

License

This extension is licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-01-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固