mongoar.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * FecShop file.
  4. *
  5. * @link http://www.fecshop.com/
  6. * @copyright Copyright (c) 2016 FecShop Software LLC
  7. * @license http://www.fecshop.com/license/
  8. */
  9. ?>
  10. <div style="margin:10px;">
  11. <br/>
  12. <?php
  13. $array = [
  14. 'title' => '一:Mongodb Active Record配置',
  15. 'description' => '',
  16. 'content' => [
  17. ['配置项','详细说明'],
  18. ['Mongodb:','
  19. Mongodb active record的定义:<br/>
  20. use common\extensions\mongodb\IActiveRecord;<br/>
  21. class ErpOrderList extends IActiveRecord <br/>
  22. { <br/>
  23. # 定义db<br/>
  24. public static function getDb()<br/>
  25. {<br/>
  26. return \Yii::$app->get(\'mongodb_erp\');<br/>
  27. }<br/>
  28. # 定义collection name <br/>
  29. public static function collectionName()<br/>
  30. { <br/>
  31. return \'erp_order_list\'; <br/>
  32. } <br/>
  33. # 定义collection 各个字段的类型定义,在保存前进行类型转换<br/>
  34. public function schema_columns(){ <br/>
  35. # 不要定义 _id <br/>
  36. return [ <br/>
  37. # id<br/>
  38. \'_id\' => \'String\',<br/>
  39. # sku<br/>
  40. \'sku\' => \'String\',<br/>
  41. #数量 <br/>
  42. \'qty\' => \'Int\',<br/>
  43. #单个SKU对应的毛收入 <br/>
  44. \'gross_default\' => \'Float\',<br/>
  45. # 单个SKU对应的毛利润 <br/>
  46. \'profit\' => \'Float\',<br/>
  47. #成本<br/>
  48. \'product_cost\' => \'Float\',<br/>
  49. #发货确认时间<br/>
  50. \'ship_confirm_date\' => \'datetime\', <br/>
  51. # 更新时间<br/>
  52. \'updated_at\' => \'datetime\',<br/>
  53. \'created_at\' => \'datetime\', <br/>
  54. ]; <br/>
  55. } <br/>
  56. }<br/>
  57. '
  58. ],
  59. ['字段说明','
  60. Int,String,Float,Datetime<br/>
  61. 详细demo参看common\models\erp\ErpOrderList;<br/>
  62. '],
  63. ],
  64. ];
  65. echo \fec\helpers\CDoc::tableformat($array);
  66. ?>
  67. <div style="clear:both"></div>
  68. </div>