2017 © Pedro Peláez
 

library database

SQL Builder With PDO, ORM etc

image

zodream/database

SQL Builder With PDO, ORM etc

  • Thursday, August 2, 2018
  • by zx648383079
  • Repository
  • 1 Watchers
  • 0 Stars
  • 58 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 14 % Grown

The README.md

database

SQL Builder With PDO, ORM etc, (*1)

注意 Model 关联查询不支持 方法名驼峰转化

$model->option_items 不会调用 $model->optionItems(), (*2)

提前预知为空不进行真实数据请求

$query->isEmpty();

model 判断是否为空 请不要轻易用 empty 关联关系时无法正确判断


$model = new Model(); $model->setRaelation('a', 122222); empty($model['a']) // true $model->relationLoaded('a') // true

关联的特殊用法

根据商品获取商品属性及属性名,, (*3)


$data = [ 'id' => 1, 'name' => 2 ]; $data = Relation::create($data, [ 't' => [ 'query' => GoodsAttributeModel::query(), 'link' => ['id', 'goods_id'], 'relation' => [ 'attr' => [ 'query' => AttributeModel::query(), 'type' => 0, 'link' => ['attribute_id', 'id'], ] ] ], ]);

最终结果如下, (*4)


{ "id": 1, "name": 2, "t": [ { "id": 10000, "goods_id": 1, "value": "11111", "attribute_id": 5, "attr": { "id": 5, "name": "尺寸" } } ] }

多级如果关联名为空则替换上一级,例如, (*5)


$data = [ 'id' => 1, 'name' => 2 ]; $data = Relation::create($data, [ 't' => [ 'query' => GoodsAttributeModel::query(), 'link' => ['id', 'goods_id'], 'relation' => [ [ 'query' => AttributeModel::query(), 'type' => 0, 'link' => ['attribute_id', 'id'], ] ] ], ]);

最终结果如下, (*6)


{ "id": 1, "name": 2, "t": [ { "id": 5, "name": "尺寸" } ] }

The Versions

02/08 2018

dev-master

9999999-dev https://github.com/zodream/database

SQL Builder With PDO, ORM etc

  Sources   Download

MIT Unlicense

The Requires

  • php >=5.6.0

 

orm sql zodream

12/07 2018

1.2

1.2.0.0 https://github.com/zodream/database

SQL Builder With PDO, ORM etc

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

orm sql zodream

09/02 2018

v1.1

1.1.0.0 https://github.com/zodream/database

SQL Builder With PDO, ORM etc

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

orm sql zodream

22/01 2018

v1.0

1.0.0.0 https://github.com/zodream/database

SQL Builder With PDO, ORM etc

  Sources   Download

Unlicense

The Requires

  • php >=5.6.0

 

orm sql zodream

15/08 2017

v0.1

0.1.0.0 https://github.com/zodream/database

SQL Builder With PDO, ORM etc

  Sources   Download

Unlicense

The Requires

  • php >=5.6.0

 

orm sql zodream