PHP Класс yii2tech\balance\ManagerDb

Configuration example: php return [ 'components' => [ 'balanceManager' => [ 'class' => 'yii2tech\balance\ManagerDb', 'accountTable' => '{{%BalanceAccount}}', 'transactionTable' => '{{%BalanceTransaction}}', 'accountBalanceAttribute' => 'balance', 'extraAccountLinkAttribute' => 'extraAccountId', 'dataAttribute' => 'data', ], ], ... ]; Database migration example: php $this->createTable('BalanceAccount', [ 'id' => $this->primaryKey(), 'balance' => $this->integer()->notNull()->defaultValue(0), ... ]); $this->createTable('BalanceTransaction', [ 'id' => $this->primaryKey(), 'date' => $this->integer()->notNull(), 'accountId' => $this->integer()->notNull(), 'extraAccountId' => $this->integer()->notNull(), 'amount' => $this->integer()->notNull()->defaultValue(0), 'data' => $this->text(), ... ]);
См. также: Manager
С версии: 1.0
Автор: Paul Klimov ([email protected])
Наследование: extends ManagerDbTransaction, use trait ManagerDataSerializeTrait
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$accountTable name of the database table, which should store account records.
$db the DB connection object or the application component ID of the DB connection. After the ManagerDb object is created, if you want to change this property, you should only assign it with a DB connection object.
$transactionTable name of the database table, which should store transaction records.

Открытые методы

Метод Описание
calculateBalance ( $account )
getAccountIdAttribute ( ) : string
getTransactionIdAttribute ( ) : string
init ( )
setAccountIdAttribute ( string $accountIdAttribute )
setTransactionIdAttribute ( string $transactionIdAttribute )

Защищенные методы

Метод Описание
createAccount ( $attributes )
createDbTransaction ( )
createTransaction ( $attributes )
findAccountId ( $attributes )
findTransaction ( $id )
incrementAccountBalance ( $accountId, $amount )

Описание методов

calculateBalance() публичный Метод

public calculateBalance ( $account )

createAccount() защищенный Метод

protected createAccount ( $attributes )

createDbTransaction() защищенный Метод

protected createDbTransaction ( )

createTransaction() защищенный Метод

protected createTransaction ( $attributes )

findAccountId() защищенный Метод

protected findAccountId ( $attributes )

findTransaction() защищенный Метод

protected findTransaction ( $id )

getAccountIdAttribute() публичный Метод

public getAccountIdAttribute ( ) : string
Результат string

getTransactionIdAttribute() публичный Метод

public getTransactionIdAttribute ( ) : string
Результат string

incrementAccountBalance() защищенный Метод

protected incrementAccountBalance ( $accountId, $amount )

init() публичный Метод

public init ( )

setAccountIdAttribute() публичный Метод

public setAccountIdAttribute ( string $accountIdAttribute )
$accountIdAttribute string

setTransactionIdAttribute() публичный Метод

public setTransactionIdAttribute ( string $transactionIdAttribute )
$transactionIdAttribute string

Описание свойств

$accountTable публичное свойство

name of the database table, which should store account records.
public $accountTable

$db публичное свойство

the DB connection object or the application component ID of the DB connection. After the ManagerDb object is created, if you want to change this property, you should only assign it with a DB connection object.
public $db

$transactionTable публичное свойство

name of the database table, which should store transaction records.
public $transactionTable