zoukankan      html  css  js  c++  java
  • PHP--TP框架----操作数据库

    //操作数据库

                       //$attr = $m->select(); //查询所有数据

                       //$attr = $m->select("p001,p002,p003");

                       //$attr = $m->find("p001"); //找特定的数据根据主键值找

                      

                       //where可以加查询条件

                       //$attr = $m->where("code='p001' or sex=true")->select();

                      

                       //table可以切换要操作的表

                       //$attr = $m->table("Nation")->select();

                      

                       //alias可以设置表的别名

                       //$attr = $m->alias("人员")->select();

                      

                       //field可以指定查询的字段

                       //$attr = $m->field("code,name")->select();

                      

                       //order可以加排序条件

                       //$attr = $m->order("Nation desc")->select();

                      

                       //group可以分组

                       //$attr = $m->field("Nation")->group("Nation")->select();

                      

                       //having可以加分组后的条件

                       //$attr = $m->field("Nation")->group("Nation")->having("count(*)>5")->select();

                      

                       //join可以连接多个表,在field里面要给字段加别名

                       $attr = $m->field("Info.Code as 代号,Info.Name as 姓名,Sex as 性别,Nation.Name as 民族名称")->join("Nation on Info.Nation = Nation.Code")->select();

                      

                      

                       var_dump($attr);

                      

                      

             }

  • 相关阅读:
    指令
    linux学习之多高并发服务器篇(三)
    linux学习之高并发服务器篇(二)
    linux学习之多高并发服务器篇(一)
    Linux学习之socket编程(二)
    Linux学习之socket编程(一)
    myeclipse中如何修改Servlet模板_day01
    Properties的使用以及配置文件值的获取
    Sql_Server中如何判断表中某字段是否存在
    微博开发流程-01
  • 原文地址:https://www.cnblogs.com/yuyu1993/p/5724215.html
Copyright © 2011-2022 走看看