## ORDER ~~~ <?php namespace Action; use HY\Action; class Index extends Action { public function Index(){ //实例User表为对象 $User = M("User"); $User->select("user_id", array( // "ORDER" => "age DESC" "ORDER" => ['age'=>'DESC'], )); // SELECT user_id FROM account // ORDER BY age // 多个排序 $User->select("user_id", array( "ORDER" => array('user_name DESC', 'user_id ASC') )); // SELECT user_id FROM account // ORDER BY "user_name" DESC, "user_id" ASC // 根据字段自定义排序顺序 // "ORDER" => array("column_name", [array #ordered array]) $User->select("user_id", array( "user_id" => array(1, 12, 43, 57, 98, 144), "ORDER" => array("user_id", array(43, 12, 57, 98, 144, 1)) )); // SELECT "user_id" // FROM "account" // WHERE "user_id" IN (1,12,43,57,98,144) // ORDER BY FIELD("user_id", 43,12,57,98,144,1) // array(6) { // [0]=> string(2) "43" // [1]=> string(2) "12" // [2]=> string(2) "57" // [3]=> string(2) "98" // [4]=> string(3) "144" // [5]=> string(1) "1" // } } } ~~~