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

                      

                      

                      

                      

                      

            

  • 相关阅读:
    (转)Entity Framework 4.1 之三(由4.0过渡到4.1/4.3)
    (转)修改的T4代码生成器(续)
    (转)【Smart Code Generator】 基于T4的代码生成器
    linux下播放mp3
    poj 2777 Count Color
    poj 1062 昂贵的聘礼
    uva 991 Safe Salutations
    uva 10587 Mayor's posters
    poj 2528 Mayor's posters
    逆序数
  • 原文地址:https://www.cnblogs.com/zzc134680/p/5724551.html
Copyright © 2011-2022 走看看