zoukankan      html  css  js  c++  java
  • ThinkPHP 3.1.2 查询方式的一般使用1

    	
    	public function show(){
    		echo "访问了index模块下的show方法!!";
    		echo "欢迎你".$_GET['name'].'你的年龄是'.$_GET['age'];
    		$m=M('user');
    	
    	    $id=$_GET['id'];
    		$arr=$m->where("id=$id")->getField('username');
    		//var_dump($arr);
    		$this->assign('data',$arr);
    		$this->display();
    	}
    
    
    
    
    	public function show(){
    		echo "访问了index模块下的show方法!!";
    		echo "欢迎你".$_GET['name'].'你的年龄是'.$_GET['age'];
    		$m=M('user');
    	
    	    $id=$_GET['id'];
    		//$arr=$m->where("id=$id")->getField('username');
    		$arr=$m->where("id=$id")->find();
    		var_dump($arr);
    		$this->assign('data',$arr);
    		$this->display();
    	}
    
    	public function show(){
    		echo "访问了index模块下的show方法!!";
    		echo "欢迎你".$_GET['name'].'你的年龄是'.$_GET['age'];
    		$m=M('user');
    	
    	    $id=$_GET['id'];
    		//$arr=$m->where("id=$id")->getField('username');
    		$arr=$m->where("id=$id")->select();
    		var_dump($arr);
    		$this->assign('data',$arr);
    		$this->display();
    	}
    
    
    
    	public function show(){
    		echo "访问了index模块下的show方法!!";
    		echo "欢迎你".$_GET['name'].'你的年龄是'.$_GET['age'];
    		$m=M('user');
    	
    	    $id=$_GET['id'];
    		//$arr=$m->where("id=$id")->getField('username');
    		$arr=$m->where("sex=1 and username='gege'")->select();
    		var_dump($arr);
    		$this->assign('data',$arr);
    		$this->display();
    	}
    
    
    //select
    
    
    	public function show(){
    		echo "访问了index模块下的show方法!!";
    		echo "欢迎你".$_GET['name'].'你的年龄是'.$_GET['age'];
    		$m=M('user');
    	
    	    $username=$_GET['username'];
    		//$arr=$m->where("id=$id")->getField('username');
    		$arr=$m->where("sex=1 and username='$username'")->find();
    		var_dump($arr);
    		$this->assign('data',$arr);
    		$this->display();
    	}
    
    
    //select 2
    
    	public function show(){
    		echo "访问了index模块下的show方法!!";
    		echo "欢迎你".$_GET['name'].'你的年龄是'.$_GET['age'];
    		$m=M('user');
    	
    	    $username=$_GET['username'];
    		
    		$sex=$_GET['sex'];
    		//$arr=$m->where("id=$id")->getField('username');
    		//$arr=$m->where("sex=$sex and username='$username'")->find();
    		
    		$data['sex']=$sex;
    		$data['username']="$username";
    		$arr=$m->where($data)->find();
    		var_dump($arr);
    		$this->assign('data',$arr);
    		$this->display();
    	}
    
    
    //select or
    
    	public function show(){
    		echo "访问了index模块下的show方法!!";
    		echo "欢迎你".$_GET['name'].'你的年龄是'.$_GET['age'];
    		$m=M('user');
    	
    	    $username=$_GET['username'];
    		
    		$sex=$_GET['sex'];
    		//$arr=$m->where("id=$id")->getField('username');
    		//$arr=$m->where("sex=$sex and username='$username'")->find();
    		
    		//默认条件是and
    		$data['sex']=$sex;
    		$data['username']="$username";
    		$data['_logic']='or';
    		$arr=$m->where($data)->select();
    		var_dump($arr);
    		$this->assign('data',$arr);
    		$this->display();
    	}
    
    //select id>6的
    
    	public function show(){
    		echo "访问了index模块下的show方法!!";
    		echo "欢迎你".$_GET['name'].'你的年龄是'.$_GET['age'];
    		$m=M('user');
    	     $id=$_GET['id'];
    	    // $username=$_GET['username'];
    		
    		// $sex=$_GET['sex'];
    		//$arr=$m->where("id=$id")->getField('username');
    		//$arr=$m->where("sex=$sex and username='$username'")->find();
    		
    		//默认条件是and
    		$data['id']=array('GT',6);
    		// $data['sex']=$sex;
    		// $data['username']="$username";
    		// $data['_logic']='or';
    		$arr=$m->where($data)->select();
    		var_dump($arr);
    		$this->assign('data',$arr);
    		$this->display();
    	}
    
    //select <=
    
    //默认条件是and
    		$data['id']=array('ELT',$id);
    		// $data['sex']=$sex;
    		// $data['username']="$username";
    		// $data['_logic']='or';
    		$arr=$m->where($data)->select();
    		var_dump($arr);
    
    
    //select like 
    
    	//默认条件是and
    		$data['username']=array('like',"%$username");
    		// $data['sex']=$sex;
    		// $data['username']="$username";
    		// $data['_logic']='or';
    		$arr=$m->where($data)->select();
    		var_dump($arr);
    		$this->assign('data',$arr);
    		$this->display();
    
    
    //select not like
    
    	$data['username']=array('notlike',"%$username");
    		// $data['sex']=$sex;
    		// $data['username']="$username";
    		// $data['_logic']='or';
    		$arr=$m->where($data)->select();
    		var_dump($arr);
    		$this->assign('data',$arr);
    		$this->display();
    	}
    
    //select like or
    
    	$data['username']=array('like',array("%$username%","%2%"));
    		// $data['sex']=$sex;
    		// $data['username']="$username";
    		// $data['_logic']='or';
    		$arr=$m->where($data)->select();
    		var_dump($arr);
    		$this->assign('data',$arr);
    		$this->display();
    
    //select like and
    
    	$data['username']=array('like',array("%$username%","%2%"),'and');
    		// $data['sex']=$sex;
    		// $data['username']="$username";
    		// $data['_logic']='or';
    		$arr=$m->where($data)->select();
    		var_dump($arr);
    
    //select between 方式
    
    	$data['id']=array('between',array($id1,$id2));
    		
    		// $data['sex']=$sex;
    		// $data['username']="$username";
    		// $data['_logic']='or';
    		$arr=$m->where($data)->select();
    		var_dump($arr);
    		$this->assign('data',$arr);
    		$this->display();
    
    
    //select not between
    
    $data['id']=array('not between',array($id1,$id2));
    		
    		// $data['sex']=$sex;
    		// $data['username']="$username";
    		// $data['_logic']='or';
    		$arr=$m->where($data)->select();
    		var_dump($arr);
    		$this->assign('data',$arr);
    		$this->display();
    
    //select in 
    
    	$data['id']=array('in ',array($id1,$id2));
    		
    		// $data['sex']=$sex;
    		// $data['username']="$username";
    		// $data['_logic']='or';
    		$arr=$m->where($data)->select();
    		var_dump($arr);
    		$this->assign('data',$arr);
    		$this->display();
    
    
    //select not in
    
    		$data['id']=array('not in ',array($id1,$id2));
    		
    		// $data['sex']=$sex;
    		// $data['username']="$username";
    		// $data['_logic']='or';
    		$arr=$m->where($data)->select();
    		var_dump($arr);
    		$this->assign('data',$arr);
    

  • 相关阅读:
    JVM-Java程序性能监控-初级篇
    一段获取app性能指标的py脚本
    一段从TXT导入excel的py脚本
    matplotlib根据Y轴数量伸缩画图的py脚本
    jsonpath读取json数据格式公用方法!!!
    python安装插件包注意事项
    Jenkins持续集成
    Jenkins简介&邮箱配置
    unittest框架扩展(基于代码驱动)自动化-下
    unittest框架扩展(自动生成用例)自动化-上
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350875.html
Copyright © 2011-2022 走看看