Skip to content

kossmoss/yii2-postgresql-array-field

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

yii2-postgresql-array-field

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)
			]
		];
	}
}

About

Yii2 postgresql array field support behavior

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages