genapi.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. chdir(dirname(dirname(dirname(__FILE__))));
  3. include './framework/router.class.php';
  4. include './framework/control.class.php';
  5. include './framework/model.class.php';
  6. include './framework/helper.class.php';
  7. /**
  8. * Gen api data
  9. *
  10. * @param string $fileName
  11. * @param array $data
  12. * @access public
  13. * @return void
  14. */
  15. function genData($fileName, $data)
  16. {
  17. global $app;
  18. $dataRoot = $app->getAppRoot() . 'db' . DS . 'api' . DS;
  19. $file = fopen($dataRoot . $fileName, 'w');
  20. fwrite($file, serialize($data));
  21. fclose($file);
  22. }
  23. /* Gen demo data to db/api. */
  24. $app = router::createApp('pms', dirname(dirname(dirname(__FILE__))), 'router');
  25. $dao = $app->loadClass('dao');
  26. $structs = $dao->select('*')->from(TABLE_APISTRUCT)->fetchAll();;
  27. $structSpecs = $dao->select('*')->from(TABLE_APISTRUCT_SPEC)->fetchAll();
  28. $apis = $dao->select('*')->from(TABLE_API)->fetchAll();
  29. $apiSpecs = $dao->select('*')->from(TABLE_API_SPEC)->fetchAll();
  30. $modules = $dao->select('*')->from(TABLE_MODULE)->where('type')->eq('api')->fetchAll();
  31. genData('apistruct', $structs);
  32. genData('apistruct_spec', $structSpecs);
  33. genData('api', $apis);
  34. genData('apispec', $apiSpecs);
  35. genData('module', $modules);