kossmoss/yii2-postgresql-array-field

Yii2 postgresql array field support behavior

0.2.1 2016-03-21 10:28 UTC

This package is not auto-updated.

Last update: 2024-04-24 20:57:07 UTC


README

Yii2 postgresql array field support behavior

================

Provides PostgreSQL array fields support for yii2 models.

Installation

Add a dependency to your project's composer.json:

{
	"require": {
		"kossmoss/yii2-postgresql-array-field": "^0.2"
	}
}

Usage example

Attach behavior to one or more fields of your model

use yii\db\ActiveRecord;
use \kossmoss\PostgresqlArrayField\PostgresqlArrayFieldBehavior;

/**
 * @property array $modelField
 */
class Model extends ActiveRecord{
	public function behaviors() {
		return [
			[
				'class' => PostgresqlArrayFieldBehavior::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)
			]
		];
	}
}