2017 © Pedro Peláez
 

yii2-extension yii2-dynamicfinder

Dynamic finder trait for Yii2-framework

image

jzfpost/yii2-dynamicfinder

Dynamic finder trait for Yii2-framework

  • Friday, January 12, 2018
  • by jzfpost
  • Repository
  • 1 Watchers
  • 1 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 15 % Grown

The README.md

yii2-dynamicfinder

Dynamic finder trait for Yii2-framework ActiveRecord models, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist jzfpost/yii2-dynamicfinder "*"

or add, (*4)

"jzfpost/yii2-dynamicfinder": "*"

to the require section of your composer.json file., (*5)

Usage

Model

use jzfpost\dynamicfinder\DynamicFinderTrait;

class Customer extends \yii\db\ActiveRecord
{
    use DynamicFinderTrait;

your code...
}

Controller

$model = Customer::findOneByEmail($email);  // return Customer::find()->where(['email' => $email])->one();
$customers = Customer::findAllByEmail($email);  // return Customer::find()->where(['email' => $email])->all();
$count = Customer::findCountByEmail($email);  // return Customer::find()->where(['email' => $email])->count();

$username = Customer::findUsernameByEmail($email); // return username value where email=$email;
$updatedAt = Customer::findUpdatedAtByEmailOrUsername($email, $username); // return updated_at value where email=$email or username = $username;
$createdAt = Customer::findCreatedAtByEmailAndUsername($email, $username); // return created_at value where email=$email and username = $username;

$customers = Customer::findByEmail($email) equivalently Customer::findAllByEmail($email);

Syntax

findBy<Field>(field_value)
find<Select>By<Field>(field_value)
find<Select>By<Field1>And<Field2>(field_value1, field_value2)
find<Select>By<Field1>Or<Field2>(field_value1, field_value2)

where:, (*6)

'Select' may by 'All', 'One', 'Count' or one of model attribute. If 'Select' not set, by default return 'All'., (*7)

'Field' is model attribute on where condition., (*8)

The Versions

12/01 2018

dev-master

9999999-dev

Dynamic finder trait for Yii2-framework

  Sources   Download

Unlicense

The Requires

 

by Avatar jzfpost

yii2

12/01 2018

1.2.1

1.2.1.0

Dynamic finder trait for Yii2-framework

  Sources   Download

Unlicense

The Requires

 

by Avatar jzfpost

yii2

15/04 2017

1.2

1.2.0.0

Dynamic finder trait for Yii2-framework

  Sources   Download

Unlicense

The Requires

 

by Avatar jzfpost

yii2