zoukankan      html  css  js  c++  java
  • 操作数据库

    操作数据库

                       $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();

                      

                      

                      

                      

                      

            

  • 相关阅读:
    poj3253Fence Repair (Huffman)
    poi3617Best Cow Line ——贪心法
    高级排序之——归并排序
    Aizu
    初级排序——冒泡排序
    cookie会话
    加载web资源文件
    servlet
    Http

  • 原文地址:https://www.cnblogs.com/zzc134680/p/5724551.html
Copyright © 2011-2022 走看看