<?php //查詢多條記錄,返回二維數組 $result = M("admin")->select(); $result = M("admin")->where("id>2")->select(); $result = M("admin")->where("id>2")->order("id desc")->limit("0,5")->field("id,username,psssword")->select(); $result = M("admin")->where("id>2")->group("messageId")->having("messageId > 3")->order("id desc")->limit("0,5")->field("id,username,psssword")->select(); //查詢一條記錄,返回一維數組 $result = M("admin")->find(); $result = M("admin")->where("id=2")->find(); //要處理的數據放在數組data中 $data = array( "username" => 'wang', "password" => "123456" ); //添加記錄,返回影響行數 $updateRowNum = M("admin")->add($data); //刪除記錄,返回影響行數 $updateRowNum = M("admin")->where("id = 2")->delete(); //修改數據放在新數組new_data中 $new_data = array( "username" => 'wang_new', "password" => "123456_new" ); //修改記錄,返回影響行數 $updateRowNum = M("admin")->where("id = 2")->save($new_data); //執行select語句(不管是多行還是一行,全部返回二維數組) $result = M()->query("select * from admin a,user u where a.id = user.aid"); //執行insert、update、delete語句,返回受影響行數 $updateRowNum = M()->execute("insert/update/delete語句"); //計算查詢行數(一般用於select語句) $row = M("admin")->select()->count(); $row = M("admin")->where("id > 3")->select()->count(); ?>