Properties

$injectionMetaCache

$injectionMetaCache : array

反射元数据缓存,避免重复反射同一个类 格式: [ ClassName => [ [property_name, attribute_instance, type_name], ... ] ]

Type

array

$instance

$instance : mixed

Type

mixed — ORM Adapter,如 LaravelORMFactory 或 ThinkphpORMFactory

$mode

$mode : ?string

Type

?string

$modelClass

$modelClass : mixed

Type

mixed — Eloquent/ThinkORM 模型类名

Methods

__construct()

__construct(?string  $mode = null, object|string|null  $modelClass = null) : mixed

Parameters

?string $mode
object|string|null $modelClass

Returns

mixed —

getAdapter()

getAdapter() : mixed

获取底层 ORM 适配器实例.

Returns

mixed —

__call()

__call(string  $name, array  $arguments) : mixed

动态代理调用 —— 将所有方法转发给 ORM Adapter.

Parameters

string $name
array $arguments

Throws

\RuntimeException

Returns

mixed —

getModel()

getModel() : mixed

Returns

mixed —

count()

count(array  $where = [], bool  $search = true) : void

Parameters

array $where = []
bool $search = true

selectList()

selectList(array  $where, string  $field = '*', int  $page = 0, int  $limit = 0, string  $order = '', array  $with = [], bool  $search = false) : void

Parameters

array $where
string $field = '*'
int $page = 0
int $limit = 0
string $order = ''
array $with = []
bool $search = false

selectModel()

selectModel(array  $where, string  $field = '*', int  $page = 0, int  $limit = 0, string  $order = '', array  $with = [], bool  $search = false) : void

Parameters

array $where
string $field = '*'
int $page = 0
int $limit = 0
string $order = ''
array $with = []
bool $search = false

getCount()

getCount(array  $where) : void

Parameters

array $where

getDistinctCount()

getDistinctCount(array  $where, mixed  $field, bool  $search = true) : void

Parameters

array $where
mixed $field
bool $search = true

getPk()

getPk() : void

getTableName()

getTableName() : void

get()

get(mixed  $id, ?array  $field = [], ?array  $with = [], string  $order = '') : void

Parameters

mixed $id
?array $field = []
?array $with = []
string $order = ''

be()

be(mixed  $map, string  $field = '') : void

Parameters

mixed $map
string $field = ''

getOne()

getOne(array  $where, ?string  $field = '*', array  $with = []) : void

Parameters

array $where
?string $field = '*'
array $with = []

value()

value(mixed  $where, ?string  $field = '') : void

Parameters

mixed $where
?string $field = ''

getColumn()

getColumn(array  $where, string  $field, string  $key = '') : void

Parameters

array $where
string $field
string $key = ''

delete()

delete(array|int|string  $id, ?string  $key = null) : void

Parameters

array|int|string $id
?string $key = null

destroy()

destroy(mixed  $id, bool  $force = false) : void

Parameters

mixed $id
bool $force = false

update()

update(string|int|array  $id, array  $data, ?string  $key = null) : void

Parameters

string|int|array $id
array $data
?string $key = null

setWhere()

setWhere(mixed  $where, ?string  $key = null) : void

Parameters

mixed $where
?string $key = null

batchUpdate()

batchUpdate(array  $ids, array  $data, ?string  $key = null) : void

Parameters

array $ids
array $data
?string $key = null

save()

save(array  $data) : void

Parameters

array $data

saveAll()

saveAll(array  $data) : void

Parameters

array $data

getFieldValue()

getFieldValue(mixed  $value, string  $filed, ?string  $valueKey = '', ?array  $where = []) : void

Parameters

mixed $value
string $filed
?string $valueKey = ''
?array $where = []

search()

search(array  $where = [], bool  $search = true) : void

Parameters

array $where = []
bool $search = true

sum()

sum(array  $where, string  $field, bool  $search = false) : void

Parameters

array $where
string $field
bool $search = false

bcInc()

bcInc(mixed  $key, string  $incField, string  $inc, string  $keyField = null, int  $acc = 2) : void

Parameters

mixed $key
string $incField
string $inc
string $keyField = null
int $acc = 2

bcDec()

bcDec(mixed  $key, string  $decField, string  $dec, string  $keyField = null, int  $acc = 2) : void

Parameters

mixed $key
string $decField
string $dec
string $keyField = null
int $acc = 2

getMax()

getMax(array  $where = [], string  $field = '') : void

Parameters

array $where = []
string $field = ''

getMin()

getMin(array  $where = [], string  $field = '') : void

Parameters

array $where = []
string $field = ''

decStockIncSales()

decStockIncSales(array  $where, int  $num, string  $stock = 'stock', string  $sales = 'sales') : void

Parameters

array $where
int $num
string $stock = 'stock'
string $sales = 'sales'

incStockDecSales()

incStockDecSales(array  $where, int  $num, string  $stock = 'stock', string  $sales = 'sales') : void

Parameters

array $where
int $num
string $stock = 'stock'
string $sales = 'sales'

inject()

inject() : void

执行依赖注入

parseInjectionMeta()

parseInjectionMeta(string  $className) : array

解析类的属性元数据

Parameters

string $className

Returns

array —

resolveDependency()

resolveDependency(object  $attr, ?string  $type) : mixed

根据注解类型解析依赖

Parameters

object $attr
?string $type

Returns

mixed —

initialize()

initialize() : void

子类可根据需要覆盖 lifecycle.

setModel()

setModel() : string

获取当前模型类名.

Returns

string —