index.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. \Qii::getInstance('ww');
  28. //可以从这里设置加载模板的路径
  29. $this->view->setTemplateDir(__DIR__ . "/view/");
  30. $this->view->display('index.tpl');
  31. }
  32. }