类定义文件
DB类:
文件\source\class\class_core.php
使用方法:C::t('tablename')->method();
插件新增的表mytablename
放置在目录:source/plugin/mypluginid/table/table_mytablename.php
使用类名:table_mytablename
使用用法:C::t('#mypluginid#mytablename')->method();
更多详细资料可参考Discuz!开发文档: http://faq.comsenz.com/library/plug/construct/construct_db.htm
DB类:
文件\source\class\class_core.php
class DB extends discuz_database {}
discuz_database类定义
文件\source\class\discuz\discuz_database.php
DB::table($table) //获取带前缀的表名
DB::delete($table, $condition, $limit = 0, $unbuffered = true) //删除数据
DB::insert($table, $data, $return_insert_id = false, $replace = false, $silent = false) //插入数据
DB::update($table, $data, $condition, $unbuffered = false, $low_priority = false)//更新
DB::insert_id()//返回插件的自增长id
DB::fetch_first($sql, $arg = array(), $silent = false) //取查询的第一条数据fetch
DB::fetch_all($sql, $arg = array(), $keyfield = '', $silent=false) //查询并fetch
DB::result_first($sql, $arg = array(), $silent = false)//查询结果集的第一个字段值
DB::query($sql, $arg = array(), $silent = false, $unbuffered = false) //普通查询 一条sql语句
DB::limit($start, $limit = 0) //limit条件
DB::order($field, $order = 'ASC')//返回排序
DB::field($field, $val, $glue = '=')//返回字段条件 $val可以为数组
另外从X2.5版本开始,discuz对数据库类进行了二次封装
数据库类定义在目录\source\class\table\使用方法:C::t('tablename')->method();
插件新增的表mytablename
放置在目录:source/plugin/mypluginid/table/table_mytablename.php
使用类名:table_mytablename
使用用法:C::t('#mypluginid#mytablename')->method();
更多详细资料可参考Discuz!开发文档: http://faq.comsenz.com/library/plug/construct/construct_db.htm