zoukankan      html  css  js  c++  java
  • 查询

    function ShowAll()
        
        {  $car = M("Car");
            var_dump($info);
            var_dump($car->select());//返回所有的二维数组
            $attr = $car->where("brand='b001'")->select();//连贯操作,select返回一个二维数组,where方法可以添加查询条件
            $attr = $car->table("Info")->select();//table可以切换表格
            $attr = $car->field("Name")->select();//指定查询的字段,查多个字段加逗号
            $attr = $car->order("Oil desc")->select();//排序,要是多个条件还是在引号里面加逗号继续
            $attr = $car->limit(2,3)->select();//分页查询,只有一个数就是取前几个数据,两个数的时候是跳过几条取几条
            $attr = $car->page(3,2)->select();//取第几页的几条数据
            $attr = $car->field("Brand,count(*)")->group("Brand")->select();//分组查询
            $attr = $car->join("Brand on Car.Brand = Brand.Brand_Code")->select();//链接查询,把两个表连接到一起
            $attr = $car->distinct(true)->field("Brand")->select();//去重查询,如果是FALSE就不能去重了,field里面是对哪一列去重
            
            
            $attr = $car->find("c001");//查询一个数据,返回的一个一位数组,只能根据主键值查询,不写参数默认返回第一条
            $attr = $car->select("c001");//返回二维数组,可以查询多个。主键值可以写多个
            
            var_dump($attr);
            
            $attr = $car->count();//差数量
    echo $attr;
    $attr = $car->select(); $this->assign("shuzu",$attr); $this->display(); }

    ShouAll.HTML

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head>
    
    <body>
    <h1>汽车表</h1>
    <table width="100%" border="1" cellpadding="0" cellspacing="0">
        <tr>
            <td>代号</td>
            <td>名字</td>
            <td>系列</td>
            <td>上市时间</td>
            <td>油耗</td>
        </tr>
        <foreach  name="shuzu" item="v">
        <tr>
            <td><{$v.code}></td>     <!--用小写-->
            <td><{$v.name}></td>
            <td><{$v.brand}></td>
            <td><{$v.time}></td>
            <td><{$v.oil}></td>
        </tr>
        </foreach>
    </table>
    </body>
    </html>
  • 相关阅读:
    机器学习项目实战----信用卡欺诈检测(二)
    机器学习项目实战----信用卡欺诈检测(一)
    机器学习之使用Python完成逻辑回归
    逻辑回归算法
    机器学习之梯度下降
    线性回归算法原理推导
    Spark之RDD容错原理及四大核心要点
    Spark之RDD依赖关系及DAG逻辑视图
    Spark之RDD弹性特性
    Spark之RDD的定义及五大特性
  • 原文地址:https://www.cnblogs.com/erinzhismile/p/5594151.html
Copyright © 2011-2022 走看看