marena/yii2-meta-trait

Providers WordPress-like meta table functionality for tables represented by an ActiveRecord class

Installs: 1 475

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 2

Type:yii2-extension

1.0.0 2023-03-02 08:12 UTC

This package is auto-updated.

Last update: 2024-03-30 00:18:41 UTC


README

Providers WordPress-like meta table functionality for tables represented by an ActiveRecord class

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist mipotech/yii2-meta-activerecord "*"

or add

"mipotech/yii2-meta-activerecord": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code as follows :

<?php

use mipotech\metaActiveRecord\MetaActiveRecord;

class User extends MetaActiveRecord
{
	...
}

To create a new record:

$user = new User;
$user->firstName = 'John';		// not part of user table schema
$user->lastName = 'Doe';		// not part of user table schema
$user->username = 'johndoe1';
$user->password = Yii::$app->security->generatePasswordHash('123456');
$user->email = 'johndoe@foobar.com';
$user->registered = time();
$ret = $user->save();

To update an existing record:

$user = User::findOne(['email'=>'johndoe@foobar.com']);
$user->firstName = 'Jane';		// not part of user table schema
$user->lastName = 'Doe1';		// not part of user table schema
$user->save();