2017 © Pedro Peláez
 

yii2-extension yii2-ensure-unique-behavior

This extension insert unique identifier automatically for the Yii 2 framework

image

jamband/yii2-ensure-unique-behavior

This extension insert unique identifier automatically for the Yii 2 framework

  • Tuesday, May 15, 2018
  • by jamband
  • Repository
  • 1 Watchers
  • 0 Stars
  • 373 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 85 % Grown

The README.md

yii2-ensure-unique-behavior

Build Status Latest Stable Version Total Downloads, (*1)

Insert unique identifier automatically for the Yii 2 framework., (*2)

Requirements

  • PHP 7.4 or later
  • Yii 2.x

Installation

composer require jamband/yii2-ensure-unique-behavior

Examples

Creates a post table:, (*3)

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:, (*4)

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:, (*5)

$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)

The Versions

15/05 2018

dev-master

9999999-dev https://github.com/jamband/yii2-ensure-unique-behavior

This extension insert unique identifier automatically for the Yii 2 framework

  Sources   Download

MIT

The Requires

 

The Development Requires

extension yii2 behavior unique

04/02 2017

v0.3.1

0.3.1.0 https://github.com/jamband/yii2-ensure-unique-behavior

This extension insert unique identifier automatically for the Yii 2 framework

  Sources   Download

MIT

The Requires

 

The Development Requires

extension yii2 behavior unique

30/01 2017

v0.3.0

0.3.0.0 https://github.com/jamband/yii2-ensure-unique-behavior

This extension insert unique identifier automatically for the Yii 2 framework

  Sources   Download

MIT

The Requires

 

The Development Requires

extension yii2 behavior unique

17/01 2017

v0.2.1

0.2.1.0 https://github.com/jamband/yii2-ensure-unique-behavior

This extension insert unique identifier automatically for the Yii 2 framework

  Sources   Download

MIT

The Requires

 

The Development Requires

extension yii2 behavior unique

22/01 2016

v0.2.0

0.2.0.0 https://github.com/jamband/yii2-ensure-unique-behavior

This extension insert unique identifier automatically for the Yii 2 framework

  Sources   Download

MIT

The Requires

 

The Development Requires

extension yii2 behavior unique

19/01 2016

v0.1.0

0.1.0.0 https://github.com/jamband/yii2-ensure-unique-behavior

This extension insert unique identifier automatically for the Yii 2 framework

  Sources   Download

MIT

The Requires

 

The Development Requires

extension yii2 behavior unique