zoukankan      html  css  js  c++  java
  • 查询方式实例演示

    User模块的方法;
    
         public function search(){
    	var_dump($_POST);
     }
     
     
     
     <!doctype html>
    <html lang="en">
     <head>
      <meta charset="UTF-8">
      <meta name="Generator" content="EditPlus?">
      <meta name="Author" content="">
      <meta name="Keywords" content="">
      <meta name="Description" content="">
      <title>Document</title>
      <script>
      function jump(){
        window.location="http://localhost:8080/thinkphp/index.php/User/add";
      }
      </script>
     </head>
     <body>
     <form action='/thinkphp/index.php/User/search' method='post'>
          用户名:<input type='text' name='username'/>
    	  性别:<input type='radio' name='sex' value='1'/>男<input type='radio' name='sex' value='0'/>女
    	  <input type='submit' value='搜素'/>
     </form>
     
      <h1>scan show 你好 hhhello world</h1>
      <table border='1' width='500' align='center'>
      <tr>
      <th>id</th>
      <th>username</th>
      <th>sex</th>
      <th>操作</th>
      </tr>
      
      <volist name='data' id='vo'>
      <tr>
         <td><{$vo.id}></td>
    	 <td><{$vo.username}></td>
    	 <td><{$vo.sex}></td>
    	 <td><a href="http://localhost:8080/thinkphp/index.php/User/del/id/<{$vo.id}>">删除</a>|<a href="http://localhost:8080/thinkphp/index.php/User/modify/id/<{$vo.id}>">修改</a></td>
      </tr>
      </volist>
      </table>
      <center>
      <button onclick="jump()">添加用户</button>
      </center>
     </body>
    </html>
    
    
    
     <form action='/thinkphp/index.php/User/search' method='post'>
     
     
     form表单的动作是 调用/thinkphp/index.php/User/search
    
    
     
          public function search(){
    	var_dump($_POST);
     }
     
     
     打印出的内容:
     
     array (size=2)
      'username' => string 'xxyy' (length=4)
      'sex' => string '1' (length=1)
      
      
      
           public function search(){
    	var_dump($_POST);
    	// 获取POSTT的数据,根据数据组查询的条件,根据条件从数据库中获取数,
    	
    	//返回给页面遍历
    
    把数据分配给前台模板,去找index的前台模板	
    	$m=M('user');
    	if 
    	$where['username']=$_POST['username']
        $where['sex']=$_POST['sex']
    	$arr=$m->where($where)->select()
    	$this->assign('data',$arr);
    	$this->display('index');
     }
     
     
     组装的SQL:
     
     SELECT * FROM `user` WHERE ( `username` = 'xxyy' ) AND ( `sex` = '0' ) [ RunTime:0.015743s ]
     
     
     	$m=M('user');
    	if (isset($_POST['username'])){
    	$where['username']=$_POST['username'];
    	 };
    	 if (isset($_POST['sex'])){
        $where['sex']=$_POST['sex'];
    	 };
    	#$where['logic']
    	echo $where['username'];
    	echo $where['sex'];
    	$arr=$m->where($where)->select();
    	$this->assign('data',$arr);
    	$this->display('index');
     }
     
     
     
     	$m=M('user');
    	if (isset($_POST['username']) && $_POST['username'] !=null ){
    	$where['username']=$_POST['username'];
    	 };
    	 if (isset($_POST['sex']) && $_POST['sex'] !=null){
        $where['sex']=$_POST['sex'];
    	 };
    	#$where['logic']
    	echo $where['username'];
    	echo $where['sex'];
    	$arr=$m->where($where)->select();
    	$this->assign('data',$arr);
    	$this->display('index');
     }
     
     
     
     等价于;
     
      <form action='/thinkphp/index.php/User/search' method='post'>
    
      
       <form action='__URL__/search' method='post'>

  • 相关阅读:
    XAF应用开发教程(七)外观控制模块
    XAF应用开发教程(五)验证模块
    XAF应用开发教程(六)控制器
    XAF应用开发教程(四)应用程序模型
    XAF应用开发教程(三)业务对象模型之引用类型与关联关系
    XAF应用开发教程(二)业务对象模型之简单类型属性
    XAF应用开发教程(一) 创建项目
    CSharp Similarities and Differences
    Nemerle Quick Guide
    2.1 确知信号的类型
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199677.html
Copyright © 2011-2022 走看看