公共方法:

    public function field ($field=null) //要返回的字段 field(‘id,username,password’)

    public function where ($condition=null) //查询条件

    public function order($order=null) //排序 order(‘id desc’)

    public function limit ($limit=null) //要获取的条数 limit(‘0,10’)

    public function select() //返回多条记录

    public function find() //返回一条记录

    public function count() //返回满足条件的数量

    public function getDbFields() //获取数据表所有字段

    public function add($data) //添加数据

    public function save($condition, $data) //更新数据

    public function delete($condition) //按条件删除($condition必填)

    public function query($sql) //原生sql查询

    public function getError() //获取错误信息

    public function getLastSql() //获取最后一条sql语句

    查询条件:

    普通查询:

    $condition[‘name’] = ‘g-framework’;

    表达式查询:

    $condition[‘id’] = array(‘eq’, 10); // id = ’10’

    $condition[‘id’] = array(‘neq’, 10); // id != ‘10’

    $condition[‘id’] = array(‘gt’, 10); // id > ‘10’

    $condition[‘id’] = array(‘egt’, 10); // id >= ‘10’

    $condition[‘id’] = array(‘lt’, 10); // id < ‘10’

    $condition[‘id’] = array(‘elt’, 10); // id <= ‘10’

    $condition[‘name’] = array(‘like’, ‘%蓝色%’); // name like ‘%蓝色%’

    $condition[‘name’] = array(‘not like’, ‘%蓝色%’); // name not like ‘%蓝色%’

    $options['id'] = array('in', '5,10'); // id in (5,10)

    $options['id'] = array('not in', '5,10'); // id not in (5,10)

    $options['id'] = array('bt', '5,10'); // id between ‘5’ and ‘10’

    $options['id'] = array('not bt', '5,10'); // id not between ‘5’ and ‘10’

    不支持区间查询,不支持array之中嵌套array

    不支持or(或条件查询)

    原生查询:

    //query方法

    $M = M();

    $M->query(‘select * from gf_user where id = 1’);

    //execute方法

    $M = M();

    $M->execute(‘update gf_user set status= ‘0’ where id = 1’);

    原文: http://www.g-framework.com/doc/36.html