denq/yii2-record-replacer

Record replacer a help tool for yii2 framework

Installs: 6

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 1

Open Issues: 1

Type:yii2-extension

0.0.4 2015-12-12 14:17 UTC

This package is not auto-updated.

Last update: 2024-11-09 18:54:12 UTC


README

Record replacer a component for safe add new records or replacing that already exists

Install

    composer require "denq/yii2-record-replacer"

Configure

    'components' => [
        'RecordReplacer' => [
            'class' => 'RecordReplacer\RecordReplacer',
        ],
        ...
    ]

Usage

    Yii::$app->RecordReplacer->Run($model, $fields, $primary)
  • $model

    • type: \yii\db\ActiveRecord
    • description: your active record model
    • required: true
  • $fields

    • type: array
    • description: array with fields and values
    • required: true
  • $primary

    • type: array
    • description: searchable fields
    • required: false
    • default value: []

Example

    Yii::$app->RecordReplacer->Run(new CustomModel, [
        'field_1' => 'val 1',
        'field_2' => 'val 2',
        ...
        'field_n' => 'val n',
    ], [
        'field_n'
    ]);