2017 © Pedro Peláez
 

library yii2-postgresql-array-field

Yii2 postgresql jsonb field support behavior

image

fgh151/yii2-postgresql-array-field

Yii2 postgresql jsonb field support behavior

  • Friday, October 7, 2016
  • by fgh151
  • Repository
  • 1 Watchers
  • 0 Stars
  • 27 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

yii2-postgresql-array-field

Yii2 postgresql object field support behavior, (*1)

================, (*2)

Provides PostgreSQL object fields support for yii2 models., (*3)

Installation

Add a dependency to your project's composer.json:, (*4)

{
    "require": {
        "fgh151/yii2-postgresql-array-field": "*"
    }
}

Migration example

$this->createTable('UserReward', [
    'jsonField' => fgh151\PostgresqlJsonb\db\Schema::TYPE_JSONB
]);

Usage example

Attach behavior to one or more fields of your model

use yii\db\ActiveRecord;
use \fgh151\PostgresqlJsonb\PostgresqlJsonbFieldBehavior;

/**
 * @property array $modelField
 */
class Model extends ActiveRecord{
    public function behaviors() {
        return [
            [
                'class' => PostgresqlJsonbFieldBehavior::className(),
                'arrayFieldName' => 'modelField', // model's field to attach behavior
                'onEmptySaveNull' => true // if set to false, empty array will be saved as empty PostreSQL array '{}' (default: true)
            ]
        ];
    }
}
$model->jsonField->property = 'value';
$model->jsonField->otherProperty->otherPropertyValue = 'another value';

The Versions

07/10 2016

dev-master

9999999-dev

Yii2 postgresql jsonb field support behavior

  Sources   Download

MIT

The Requires