{"id":14966775,"url":"https://github.com/tigrov/yii2-pgsql","last_synced_at":"2025-10-25T17:30:37.502Z","repository":{"id":46619727,"uuid":"71594990","full_name":"Tigrov/yii2-pgsql","owner":"Tigrov","description":"Improved PostgreSQL schemas for Yii2","archived":false,"fork":false,"pushed_at":"2021-10-10T09:33:06.000Z","size":90,"stargazers_count":34,"open_issues_count":2,"forks_count":6,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-02-06T02:08:26.779Z","etag":null,"topics":["pgsql","postgres","postgresql","yii2","yii2-extension"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tigrov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-21T20:39:48.000Z","updated_at":"2024-05-08T12:56:07.000Z","dependencies_parsed_at":"2022-09-17T22:50:30.594Z","dependency_job_id":null,"html_url":"https://github.com/Tigrov/yii2-pgsql","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tigrov%2Fyii2-pgsql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tigrov%2Fyii2-pgsql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tigrov%2Fyii2-pgsql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tigrov%2Fyii2-pgsql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tigrov","download_url":"https://codeload.github.com/Tigrov/yii2-pgsql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238183692,"owners_count":19430171,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pgsql","postgres","postgresql","yii2","yii2-extension"],"created_at":"2024-09-24T13:36:55.677Z","updated_at":"2025-10-25T17:30:36.989Z","avatar_url":"https://github.com/Tigrov.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"yii2-pgsql\n==============\n\nImproved PostgreSQL schemas for Yii2.\n\nYii 2.0.14 and above supports `array` and `json` DB types.\n\nSupports follow types for ActiveRecord models:\n* `array`, Yii 2.0.14 and above supports `array` DB type\n* `json`, Yii 2.0.14 and above supports `json` DB type\n* [`composite`](docs/composite.md), https://www.postgresql.org/docs/current/static/rowtypes.html\n* `domain`, https://www.postgresql.org/docs/current/static/sql-createdomain.html\n* fixes type `bit`, issue [#7682](https://github.com/yiisoft/yii2/issues/7682)\n* converts Postgres types `timestamp`, `date` and `time` to PHP type `\\DateTime` and vice versa.\n\n[![Latest Stable Version](https://poser.pugx.org/Tigrov/yii2-pgsql/v/stable)](https://packagist.org/packages/Tigrov/yii2-pgsql)\n[![Build Status](https://travis-ci.org/Tigrov/yii2-pgsql.svg?branch=master)](https://travis-ci.org/Tigrov/yii2-pgsql)\n\nLimitation\n------------\n\nSince version 1.2.0 requires Yii 2.0.14 and above.  \nYou can use version 1.1.11 if you have Yii 2.0.13 and below.\n\nInstallation\n------------\n\nThe preferred way to install this extension is through [composer](http://getcomposer.org/download/).\n\nEither run\n\n```\nphp composer.phar require --prefer-dist tigrov/yii2-pgsql\n```\n\nor add\n\n```\n\"tigrov/yii2-pgsql\": \"~1.0\"\n```\n\nto the require section of your `composer.json` file.\n\n \nConfiguration\n-------------\nOnce the extension is installed, add following code to your application configuration:\n\n```php\nreturn [\n    //...\n    'components' =\u003e [\n        'db' =\u003e [\n            'class' =\u003e 'yii\\db\\Connection',\n            'dsn' =\u003e 'pgsql:host=localhost;dbname=\u003cdatabase\u003e',\n            'username' =\u003e 'postgres',\n            'password' =\u003e '\u003cpassword\u003e',\n            'schemaMap' =\u003e [\n                'pgsql'=\u003e 'tigrov\\pgsql\\Schema',\n            ],\n        ],\n    ],\n];\n```\n\nSpecify the desired types for a table\n```sql\nCREATE TABLE public.model (\n    id serial NOT NULL,\n    attribute1 text[],\n    attribute2 jsonb,\n    attribute3 timestamp DEFAULT now(),\n    CONSTRAINT model_pkey PRIMARY KEY (id)\n);\n```\n\nConfigure Model's rules\n```php\n/**\n * @property string[] $attribute1 array of string\n * @property array $attribute2 associative array or just array\n * @property integer|string|\\DateTime $attribute3 for more information about the type see \\Yii::$app-\u003eformatter-\u003easDatetime()\n */\nclass Model extends ActiveRecord\n{\n    //...\n    public function rules()\n    {\n        return [\n            [['attribute1'], 'each', 'rule' =\u003e ['string']],\n            [['attribute2', 'attribute3'], 'safe'],\n        ];\n    }\n}\n```\n\t\nUsage\n-----\n\nYou can then save array, json and timestamp types in database as follows:\n\n```php\n/**\n * @var ActiveRecord $model\n */\n$model-\u003eattribute1 = ['some', 'values', 'of', 'array'];\n$model-\u003eattribute2 = ['some' =\u003e 'values', 'of' =\u003e 'array'];\n$model-\u003eattribute3 = new \\DateTime('now');\n$model-\u003esave();\n```\n\nand then use them in your code\n```php\n/**\n * @var ActiveRecord $model\n */\n$model = Model::findOne($pk);\n$model-\u003eattribute1; // is array\n$model-\u003eattribute2; // is associative array (decoded json)\n$model-\u003eattribute3; // is \\DateTime\n```\n\n[Composite types](docs/composite.md)\n\nLicense\n-------\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftigrov%2Fyii2-pgsql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftigrov%2Fyii2-pgsql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftigrov%2Fyii2-pgsql/lists"}