class DB
{ function table($table) {
return DB::_execute('table_name', $table);
} function delete($table, $condition, $limit = 0, $unbuffered = true) {
if(empty($condition)) {
$where = '1';
} elseif(is_array($condition)) {
$where = DB::implode_field_value($condition, ' AND ');
} else {
$where = $condition;
}
$sql = "DELETE FROM ".DB::table($table)." WHERE $where ".($limit ? "LIMIT $limit" : '');
return DB::query($sql, ($unbuffered ? 'UNBUFFERED' : ''));
} function insert($table, $data, $return_insert_id = false, $replace = false, $silent = false) { $sql = DB::implode_field_value($data); $cmd = $replace ? 'REPLACE INTO' : 'INSERT INTO'; $table = DB::table($table);
$silent = $silent ? 'SILENT' : ''; $return = DB::query("$cmd $table SET $sql", $silent); return $return_insert_id ? DB::insert_id() : $return; }
我在其它文件中引入了这个文件。
但是我要怎么调用呢?
谁能把这段代码帮注解一下么?

解决方案 »

  1.   

    if(!defined('IN_DISCUZ')) {
    exit('Access Denied');
    }
    require_once './source/class/class_core.php';
    $query = DB::query("SELECT * FROM ".DB::table('forum_plugin') WHERE id ='1'");
    while($plugin = DB::fetch($query)) {
    echo "----".$plugin[t].$plugin[d];
    }
    无显示!!
      

  2.   

    是自己做插件吗?如果是自己做插件,不需要自己引用,因为在common.inc.php里面已经引用并加载对象了,只要调用DB即可。
    比如
    $total = DB::result_first("SELECT count(*) as c FROM ".DB::table('common_kb')." $sql");如果在其他的文件,自己调用./source/class/class_core.php文件后,再加一句
    $discuz = & discuz_core::instance();
    即可在后面用DB了。
      

  3.   


    x1.5里common.inc.php这个文件了。
      

  4.   

    数据库操作类和核心类都在里面。
    要运行discuz核心的东西,至少需要引入他们。否则无法开始。
      

  5.   


    discuz 1.5已经没有common.ini.php 文件了。