> 当我们需要查询的时候,我们可以通过`select`方法来进行操作,下面是查询user表作为例子: ```php $select = Db('user')->select([ 'field' => ['username', 'email'], //设定查询的字段 'where' => [ //定义查询的条件 'age' => array('>',20), 'gender' => '0' ], 'limit' => '0, 10', //条数限制 'orderby' => 'username asc', //进行排序 ])->get(); //sql:SELECT `username`,`email` FROM `user` WHERE `age` > 20 and `gender`=0 ORDER BY username asc LIMIT 0,10 if($select !== false){ echo '查询成功'; }else{ echo '查询失败'; } ``` 基本返回 ``` Db('操作的表名','您要操作的数据库标识,忽略则为默认连接')->select(查询的可选条件); ``` > 查询失败返回false,查询成功返回多维数组: ``` ( [0] => Array ( [username] => John doe [email] => john@email.com ) ) ``` * * * * * >当我们不需要返回多条数据的时候,我们可以通过find方法来获取 ```php $select = Db('user')->select([ 'field' => ['username', 'email'], //设定查询的字段 'where' => [ //定义查询的条件 'id' => 30 ], 'limit' => '1', //条数限制 'orderby' => 'username asc', //进行排序 ])->find(); //sql:SELECT `username`,`email` FROM `user` WHERE `id` = 30 ORDER BY username asc LIMIT 1 if($select !== false){ echo '查询成功'; }else{ echo '查询失败'; } ``` 返回数据: ``` ( [username] => John doe [email] => john@email.com ) ```