'一:Mongodb Active Record配置', 'description' => '', 'content' => [ ['配置项','详细说明'], ['Mongodb:',' Mongodb active record的定义:
use common\extensions\mongodb\IActiveRecord;
class ErpOrderList extends IActiveRecord
{
# 定义db
public static function getDb()
{
return \Yii::$app->get(\'mongodb_erp\');
}
# 定义collection name
public static function collectionName()
{
return \'erp_order_list\';
}
# 定义collection 各个字段的类型定义,在保存前进行类型转换
public function schema_columns(){
# 不要定义 _id
return [
# id
\'_id\' => \'String\',
# sku
\'sku\' => \'String\',
#数量
\'qty\' => \'Int\',
#单个SKU对应的毛收入
\'gross_default\' => \'Float\',
# 单个SKU对应的毛利润
\'profit\' => \'Float\',
#成本
\'product_cost\' => \'Float\',
#发货确认时间
\'ship_confirm_date\' => \'datetime\',
# 更新时间
\'updated_at\' => \'datetime\',
\'created_at\' => \'datetime\',
];
}
}
' ], ['字段说明',' Int,String,Float,Datetime
详细demo参看common\models\erp\ErpOrderList;
'], ], ]; echo \fec\helpers\CDoc::tableformat($array); ?>