$car = M("Car"); var_dump($car->select()); //返回所有数据的二维数组 $attr = $car->where("brand=‘b002‘")->select();//where方法可以添加查询条件 $attr = $car->table("Nation")->select();//table方法可以切换操作表 $attr = $car->field("Code,Name")->select();//可以指定查询的字段 $attr = $car->order("Oil desc")->select();//排序 $attr = $car->limit(2,2)->select(); //分页查询,如果一个参数n的话就是取前n个 $attr = $car->page(3,2)->select();//扩展,取第n页的几条数据 $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();//去重 $attr = $car->find();//根据主键取一条数据,不写主键值默认返回第一条 $attr = $car->select("c001,c002"); //根据主键值查询,返回二维数组 $attr = $car->where("Name like ‘%奥迪%‘")->order("Powers desc")->select();
时间: 2024-10-12 02:19:59