Exemplo n.º 1
0
 /** 
  * 默认动作
  * Yaf支持直接把Yaf_Request_Abstract::getParam()得到的同名参数作为Action的形参
  * 对于如下的例子, 当访问http://yourhost/{&$APP_NAME&}/index/index/index/name/{&$AUTHOR&} 的时候, 你就会发现不同
  */
 public function indexAction($name = "Stranger")
 {
     $get = $this->getRequest()->getQuery("get", "default value");
     $model = new SampleModel();
     $this->getView()->assign("content", $model->selectSample());
     $this->getView()->assign("name", $name);
 }
Exemplo n.º 2
0
 /** 
  * 默认动作
  * Yaf支持直接把Yaf_Request_Abstract::getParam()得到的同名参数作为Action的形参
  * 对于如下的例子, 当访问http://yourhost/php/index/index/index/name/ 的时候, 你就会发现不同
  */
 public function indexAction($name = "Stranger")
 {
     //1. fetch query
     $get = $this->getRequest()->getQuery("get", "default value");
     //2. fetch model
     $model = new SampleModel();
     //3. assign
     $this->getView()->assign("content", $model->selectSample());
     $this->getView()->assign("name", $name);
     //4. render by Yaf, 如果这里返回FALSE, Yaf将不会调用自动视图引擎Render模板
 }
Exemplo n.º 3
0
 /** 
  * 默认动作
  * Yaf支持直接把Yaf_Request_Abstract::getParam()得到的同名参数作为Action的形参
  * 对于如下的例子, 当访问http://yourhost/yaf-php7/index/index/index/name/Mike 的时候, 你就会发现不同
  */
 public function indexAction(string $name = "Mike")
 {
     //1. fetch query
     $id = $this->getRequest()->getQuery('id');
     //2. fetch model
     $model = new SampleModel();
     //3. assign
     $this->getView()->assign("content", $model->selectSample());
     $this->getView()->assign("name", $name);
     $this->getView()->assign("id", $id);
     //4. render by Yaf, 如果这里返回FALSE, Yaf将不会调用自动视图引擎Render模板
     return TRUE;
 }
Exemplo n.º 4
0
 /** 
  * 默认动作
  * Yaf支持直接把Yaf_Request_Abstract::getParam()得到的同名参数作为Action的形参
  * 对于如下的例子, 当访问http://yourhost/sample/index/index/index/name/wenbo-pc\wenbo 的时候, 你就会发现不同
  */
 public function indexAction($name = "Stranger")
 {
     //1. fetch query
     header("Content-type: text/html; charset=utf-8");
     $get = $this->getRequest()->getQuery("get", "default value");
     //2. fetch model
     $model = new SampleModel();
     // var_dump($model);
     //$this->redirect("index/login");
     // $echo=new echo();
     // $echo->echoname();
     //3. assign
     $this->getView()->assign("content", $model->selectSample());
     $this->getView()->assign("name", $name);
     //4. render by Yaf, 如果这里返回FALSE, Yaf将不会调用自动视图引擎Render模板
     return true;
 }
Exemplo n.º 5
0
 /**
  * 默认动作
  * Yaf支持直接把Yaf_Request_Abstract::getParam()得到的同名参数作为Action的形参
  * 对于如下的例子, 当访问http://yourhost/sample/index/index/index/name/chenzhidong 的时候, 你就会发现不同
  */
 public function indexAction($name = "Stranger")
 {
     //1. fetch query
     $get = $this->getRequest()->getQuery("get", "default value");
     //2. fetch model
     $model = new SampleModel();
     //setDatas
     $model->setDatas(array('email' => '*****@*****.**', 'nick' => 'nick', 'passwd' => '123456', 'ip_address' => Tools::getRemoteAddr()));
     //3. assign
     $this->_view->assign('content', $model->selectSample());
     $this->_view->assign('name', $name);
     //cache用法
     //Cache::getInstance()->get($key);
     //Cache::getInstance()->set($key);
     //4. render by Yaf, 如果这里返回FALSE, Yaf将不会调用自动视图引擎Render模板
     return true;
 }
Exemplo n.º 6
0
 public function testAction($name = "Stranger", $password = "")
 {
     echo $_SESSION['username'];
     //1. fetch query
     $get = $this->getRequest()->getQuery("get", "default value");
     //这个可以获取两种方式提交的name和value
     //print_r( $this->getRequest()->getParams($name,'ddd'));
     echo $this->getRequest()->getMethod();
     //2. fetch model
     $model = new SampleModel();
     //3. assign
     $this->getView()->assign("content", $model->selectSample());
     $this->getView()->assign("name", $name);
     //$this->display("index",array("name"=>ddddddddd));
     //4. render by Yaf, 如果这里返回FALSE, Yaf将不会调用自动视图引擎Render模板
     //$this->db = Yaf_Registry::get('_db');
     //print_r($this->db);
     return TRUE;
 }
Exemplo n.º 7
0
 public function testAction()
 {
     $model = new SampleModel();
     echo $model->selectSample();
     return FALSE;
 }