solve/数据库

数据库引擎

v2.0.19 2015-07-20 02:59 UTC

README

解决框架的数据库组件

已完成

QC
MysqlDBAdaptor
DBOperator
ModelOperator
ModelStructure

Model
ModelCollection
ModelRelation

SlugAbility
TranslateAbility
FilesAbility (+thumbnails)

Validation

需要实现

排序能力 时间跟踪能力 树形能力 历史能力 动态能力

分页器

示例模型结构

品牌

table: brands
columns:
  id:
    type: 'int(11) unsigned'
    auto_increment: true
  title:
    type: varchar(255)
indexes:
  primary:
    columns:
      - id
relations:
  products: {  }
# here we have autodetect for model, for relation type and related field names

类别

table: categories
columns:
  id:
    type: 'int(11) unsigned'
    auto_increment: true
  title:
    type: varchar(255)
indexes:
  primary:
    columns:
      - id
relations:
  products: {  }

产品

table: products
columns:
  id:
    type: 'int(11) unsigned'
    auto_increment: true
  title:
    type: varchar(255)
  id_brand:
    type: 'int(11) unsigned'
indexes:
  primary:
    columns:
      - id
relations:
  brand: {  }
  categories: {  }

简单操作

$product = Product::loadOne(1);
$product->title = 'Macbook air';
$product->save();

$product = new Product();
$product->title = 'Macbook pro'
$product->save();

$list = Product::loadList(QC::create()->where('id < :d', 3));
//$list->loadRelated('brand'); - optional
echo $list->getFirst()->brand->id;
$list->getFirst()->setRelatedBrand(1); // set related by id