最近接到一個(gè)帝國CMS模板改版項(xiàng)目,自帶的數(shù)據(jù)可能是采集的,以前的簡介字段內(nèi)容只截取了60個(gè)字,新模板的簡介60字符太少了,不美觀,想讓簡介都截取200個(gè)字,怎么批量修改呢,文章太多了手動改肯定不行,網(wǎng)上查了下帝國CMS教程。分享一段可用代碼。
1、先備份數(shù)據(jù)庫
2、保存e/admin/ChangeByID.php
<?php define('EmpireCMSAdmin','1'); require("../class/connect.php"); require("../class/db_sql.php"); require("../class/functions.php"); require LoadLang("pub/fun.php"); require("../class/t_functions.php"); require("../data/dbcache/class.php"); require("../data/dbcache/MemberLevel.php"); $link=db_connect(); $empire=new mysqlquery(); $tbname="news"; $sid=(int)$_GET['startid']; $b=0; $rs=$empire->query("SELECT id,newstext FROM {$dbtbpre}ecms_{$tbname}_data_1 WHERE id>{$sid} limit 20"); while($r=$empire->fetch($rs)) { $smalltext=''; !$r['newstext'] or $smalltext=SubSmalltextVal($r['newstext'],200); $smalltext=addslashes($smalltext); $smalltext && $empire->query("UPDATE {$dbtbpre}ecms_{$tbname} SET smalltext='{$smalltext}' WHERE id=".$r[id]); $b=$r['id']; } $b or exit('轉(zhuǎn)換結(jié)束!'); echo "<meta http-equiv=\"refresh\" content=\"1;url=ChangeByID.php?startid=".$b."\">"; echo "已轉(zhuǎn)換ID".$b; db_close(); $empire=null; ?>
3、瀏覽器訪問ChangeByID.php
版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會員發(fā)布,如果侵犯了您的權(quán)益請與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!
轉(zhuǎn)載請注明: 帝國CMS批量提取正文內(nèi)容到簡介