好文档就是一把金锄头!
欢迎来到金锄头文库![会员中心]
电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

DZ数据库类详解.doc

10页
  • 卖家[上传人]:ss****gk
  • 文档编号:205629926
  • 上传时间:2021-10-29
  • 文档格式:DOC
  • 文档大小:100KB
  • / 10 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • Discuz数据库类/*** 返回表名(pre_$table)** @param 原始表名 Stable* @return增加pre之后的名字*/function table (Stable) {案例代码:Sname = DB::result_first("SELECT name FROM".DB::tabIe(common_advertisement_custom)." WHERE id=$_G[gp_id]");/*删除一条或者多条记录** @param string $ table 原始表名* @param string $condition 条件语句,不需要写 WHERE* @param int 删除条目数* @param boolean $unbuffered 立即返回?*/function delete (Stable, $condition, $limit = 0, $unbuffered = true) {}案例代码:DB: :delete( forum_postcomment, "id二$commentid “);/***插入一条记录** @param string Stable 原始表名* @param array $data 数组 field->vlaue 对* @param boolen $return_insert_id 返回 InsertID?* @param boolen $replace 是否是 REPLACE 模式* @param boolen $silent 屏蔽错误?* @return InscrtID or Result */function insert($table, $data, $return_insert_id 二 false, Sreplace = false, $silent = false) {}案例代码:$userdata = array(uid1 => $uid,username, => Susername, password1 => $password, email* => $email, adminid1 => 0, groupid1 => $groupinfo「groupicT], regdate1 => TIMESTAMP, ^credits => $init_arr[0], timeoffset => 9999);DB::insrt(common_member; $userdata);/**更新一条或者多条数据记录** @param string Stable 原始表名* @param array $data 数据 field-value* @param string $condition 条件语句,不需要写 WHERE* @param boolean $unbuffered 迅速返回?* @param boolan $low_priority 延迟更新?* @return result*/function update($table, $data, $condition, $unbuffered = false, $low priority = false) {案例代码:DB:: update(common_member;array(adminicT => $adminidnew, ^roupid* => $groupidnew,),nuid=,$member[uidJ,M);/***格式化field字段和value,并组成一个字符串** @param array $ array 格式为 key=>value 数组* @param 分割符 $glue* @return string*/function implode_field_value($array, $glue 二,){ }/***返回插入的ID** @return int*/function insert_id() {}案例代码:DB::query("INSERT INTO ".DB::table(forum_attachment)." (tid, pid, dateline, readperm, price, filename, filetype, filesize, attachment, downloads, isimage, uid, thumb, remote, width) VALUES (O, O, $_G[timestamp]: O,();n.$upload->attach[name].", ".$upload->attach[type].M, ",.$upload->attach[size].H,M.$upload->attach[attachment]."\ 0; H.$upload->attach[isimage].M.$this->uid."\ $thumb\ ^remote, $width)");$this->aid = DB::insert_id();/***依据查询结果,返回一行数据** @param resourceID $resourceid* @return array*/function fetch($resourceid, $type = \1YSQL_ASSOC) {}案例代码:while($row = DB::fetch($query)) {$opname = $optionids[$sortid] [$rowfoptionidH; if(empty($inserts[$row[tid]])) {$inserts[$row[tid]][tid] = $row[tid];$inserts[$row[tidJJ[fidJ = SrowLfidJ;}$inserts[$row[tidlir$opname] = addslashes($row f value]);*依据SQL文,返回一条查询结果** @param string $query 查询语句* @return array*/function fetch first($sql) {案例代码:$data = DB::fetch Jirst(nSELECT COUNT(*) AS threads, SUM(replies)+COUNT(*) AS posts FROM u.DB::table($threadtable).n WHERE fid={$fonim[fid]} AND displayorder>=On,);/***依据查询结果,返回结果数值** @param resourceid $resourceid* @return string or int */function result ($resourccid, $row = 0) {/***依据查询语句,返回第一条结果数值** @param string $query SQL 查询语句* @return unknown*/function result_first ($sql) {案例代码:$name = DB::result_first("SELECT name FROMH.DB::table(,common advertisement customl).n WHERE id=,$G[gp id]M,);*执行查询** @param string $sql* @param 类型定义 $type UNBUFFERED OR SILENT* @return Resource OR Result*/function query($sql, $typc 二){案例代码:Squery = DB::query(HSELECT * FROM ,.DB::table(,common_addon,).u ORDER BY system DESC,key ASCH);DB::query(MDELETE FROM ".DB::table(common_syscache)." WHERE cname=,admingroup_$id,H);DB::query(UPDATE \DB::table(,home_blog_category,)." SET ".implode(7,$sets)." WHERE catid = ,$key,M);/***返回select的结果行数** @param resource $resourceid* @return int*/function num rows($resourceid) {}案例代码:$rows = DB::query($selectsql); $numrows = DB::num_rows($rows);*返回sql语句所影响的记录行数,(删除,修改)** @return int*/function affected_rows() {}案例代码:DB:: query ("UPDATE DB:: table forum thread)." SET displayorder=,0J, moderated二T WHERE tid IN ($tids)");$threadsmod = DB::affected_rows();/* 释放记录集*function frcc_rcsult($qucry) {*/案例代码:$query = DB:: query ("SELECT aid FROMz,. DB:: table(,portal_article_title,).WHERE title LIKE %$srchtxtsql% ORDER BY aid DESC LIMIT$_G[,setting ] [ search ] [ portal ] [ maxsearchresul ts]);while($articlc = DB::fetch($query)) {$ids .二$article[,aid* ];$num++;}DB::free_result($query);。

      点击阅读更多内容
      关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
      手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
      ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.