index.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace controller;
  3. class index extends \Qii\Base\Controller
  4. {
  5. public $enableDB = true;
  6. public $enableView = true;
  7. public function indexAction()
  8. {
  9. return $this->setResponse(new \Qii\Base\Response(array('format' => 'html', 'body' => 'This is html')));
  10. return;
  11. $data = array();
  12. $data['lists'][] = $this->db->getRow('SELECT * FROM ipAddress ORDER BY id DESC LIMIT 1');
  13. $data['lists'][] = $this->db->getRow('SELECT * FROM ipAddress ORDER BY id ASC LIMIT 1');
  14. $data['querySeconds'] = $this->db->querySeconds;
  15. return new \Qii\Base\Response(array('format' => 'json', 'body' => $data));
  16. }
  17. public function dispatchAction()
  18. {
  19. $this->dispatch('test', 'index');
  20. }
  21. public function forwardAction()
  22. {
  23. $this->setForward('test', 'index');
  24. }
  25. public function displayAction()
  26. {
  27. //可以从这里设置加载模板的路径
  28. $this->view->setTemplateDir(__DIR__ . "/view/");
  29. echo $this->view->fetch('index.tpl');
  30. }
  31. }