update.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * 更新规则页面
  4. * @author Jinhui Zhu <jinhui.zhu@live.cn>2015-09-21
  5. *
  6. */
  7. namespace actions\database;
  8. use Qii\Base\Action;
  9. class update extends Action
  10. {
  11. public $enableView = true;
  12. public $enableDB = true;
  13. public function __construct()
  14. {
  15. parent::__construct();
  16. }
  17. /**
  18. * 创建规则
  19. * @author Jinhui Zhu 2015-08-23
  20. */
  21. public function run()
  22. {
  23. try {
  24. $database = $this->request->get('__database');
  25. $tableName = $this->request->get('__tableName');
  26. $pri = explode(',', $this->request->get('__pri', ''));
  27. $val = array();
  28. foreach ($pri AS $key) {
  29. $val[$key] = $this->request->get($key);
  30. }
  31. if (!$database || !$tableName || !$pri || !$val) {
  32. throw new \Exception('参数不正确', __LINE__);
  33. }
  34. $rules = $this->controller->load->model('table')->getRules($database, $tableName);
  35. $data = $this->controller->load->model('table')->loadDataFromTable($database, $tableName, $pri, $val);
  36. $this->controller->view->assign('database', $database);
  37. $this->controller->view->assign('tableName', $tableName);
  38. $this->controller->view->assign('pri', $pri);
  39. $this->controller->view->assign('rules', $rules);
  40. $this->controller->view->assign('val', $val);
  41. $this->controller->view->assign('data', $data);
  42. $this->controller->view->display('manage/data/update.html');
  43. } catch (Exception $e) {
  44. $this->showErrorPage($e->getMessage());
  45. }
  46. }
  47. }