如何让自己的本地APACHE服务器支持.htaccess

解决问题:

如何让自己的本地APACHE服务器支持”.htaccess”呢?其实只要简单修改一下apache的httpd.conf设置就可以让APACHE支持.htaccess了,来看看操作

打开httpd.conf文件(在那里? APACHE目录的CONF目录里面),用文本编辑器打开后,查找
(1)
Options FollowSymLinks
AllowOverride None

改为
Options FollowSymLinks
AllowOverride All
(2)去掉下面的注释
LoadModule rewrite_module modules/mod_rewrite.so

就可以了


关注公众号,了解更多it技术(it问答网

sql语句防注入攻击

and a.title like ‘%25$inp_search%25’ escape ‘`’

supesite block

function DelAllergic($inp_search){
$inp_search = str_replace(“‘” , “””, $inp_search);
$inp_search = str_replace(“_” , “`_”, $inp_search);
$inp_search = str_replace(“%” , “`%”, $inp_search);
$inp_search = str_replace(“/” , “`%5C”, $inp_search);
$inp_search = str_replace(“\\” , “`%2F”, $inp_search);
return $inp_search;
}


关注公众号,了解更多it技术(it问答网

PHP获得文件创建、修改、访问时间

PHP filectime() 函数
定义和用法
filectime() 函数返回指定文件的上次 inode 修改时间。

该函数返回文件上次 inode 被修改的时间。如果出错则返回 false。时间以 Unix 时间戳的方式返回。
语法
fileatime(filename) filename 必需。规定要检查的文件。
提示和注释
提示:本函数的结果会被缓存。请使用 clearstatcache() 来清除缓存。

注意:在大多数 Unix 文件系统中,当一个文件的 inode 数据被改变时则该文件被认为是修改了。也就是说,当文件的权限,所有者,所有组或其它 inode 中的元数据被更新时。参见 filemtime()(这才是你想用于在 Web 页面中建立“最后更新时间”脚注的函数)和 fileatime()。

注释:某些 Unix 说明文本中把 ctime 说成是该文件建立的时间,这是错的。在大多数 Unix 文件系统中,没有 Unix 文件的建立时间。
PHP filemtime()函数
定义和用法
filemtime() 函数返回文件内容上次的修改时间。若成功,则时间以 Unix 时间戳的方式返回。若失败,则返回 false。
语法
filemtime(filename) filename 必需。规定要检查的文件。
说明
本函数返回文件中的数据块上次被写入的时间,也就是说,文件的内容上次被修改的时间。
提示和注释
提示:本函数的结果会被缓存。请使用 clearstatcache() 来清除缓存。
PHP fileatime()函数
定义和用法
fileatime() 函数返回指定文件的上次访问时间。

该函数返回文件上次被访问的时间。如果出错则返回 false。时间以 Unix 时间戳的方式返回。
语法
fileatime(filename) filename 必需。规定要检查的文件。
提示和注释
提示:本函数的结果会被缓存。请使用 clearstatcache() 来清除缓存。

注释:文件的 atime 应该在不论何时读取了该文件中的数据块时被更改。当一个应用程序定期访问大量文件或目录时很影响性能。有些 Unix 文件系统可以在加载时关闭 atime 的更新以提高这类程序的性能。USENET 新闻组假脱机是一个常见的例子。在这种文件系统下,本函数没有用处。

实例

< ?php
$a=filectime(“log.txt”);
echo “创建时间:”.date(“Y-m-d H:i:s”,$a).”
“;
$a=filemtime(“log.txt”);
echo “修改时间:”.date(“Y-m-d H:i:s”,$a).”
“;
$a=fileatime(“log.txt”);
echo “访问时间:”.date(“Y-m-d”,$a).”
“;
?>


关注公众号,了解更多it技术(it问答网

最新完美版本-jquery分批执行

<!–

作者:xuduowei

时间:2011年6月

–>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml“>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<!– title文字 –>
<title>网站查错</title>
<link rel=”stylesheet” href=”/css/css1.css” type=”text/css” />
<script src=”/js/jquery.js” ></script>
<script src=”/js/project.js” ></script>
<script language=”JavaScript” src=”/js/adminJs/dj.js”></script>
<style type=”text/css”>
#table_title1,#table_title2,#table_title3{background-color:#FFF;padding:4px;}
#table_title3{text-align:center;}
#table_title2{ color:#000;font-style:normal;font-weight:500;}
</style>
</head>

<body>
<!– 内容是总体一个 table–>
<table width=”100%” border=”0″ align=”center” cellpadding=”0″ cellspacing=”0″>
<!– 第1个tr开始–>
<tr>
<td width=”7″><img src=”/images/images1/c_03.jpg” width=”7″ height=”32″ /></td>

<td width=”100%” background=”/images/images1/c_05.jpg”>
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr>
<td width=”40″ align=”center”><img src=”/images/images1/c_10.jpg” width=”21″ height=”25″ /></td>
<td align=”left” class=”lanse”>
<!– 标题栏文字 –>
<strong>网站查错</strong>
</td>
<td width=”104″ align=”right” valign=”top” class=”lanse”></td>
</tr>
</table>
</td>

<td width=”7″><img src=”/images/images1/c_07.jpg” width=”7″ height=”32″ /></td>
</tr>
<!– 第1个tr结束–>

<!– 第2个tr开始–>
<tr valign=top id=”pageAutoHeightTr”>
<td background=”/images/images1/c_18.jpg”></td>

<td >

<!– 这个table里面放的是 搜索栏的内容 –>
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″ height=”35″ align=”center”  bgcolor=”#f3f3f3″ style=”border:1px solid #bebebe;”>
<tr >
<td width=”22″ height=”33″>&nbsp;</td>
<td width=”456″>

</td>
<td width=”333″>
<!– 这里是搜索按钮 –>
</td>

<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>

<!– 正文内容开始 –>
<!– 第一个表格开始 –>
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr>
<td height=”10″ colspan=”3″>&nbsp;</td>
</tr>
<tr>
<td width=”10″ height=”132″>&nbsp;</td>
<td>

<table width=”100%” border=”0″ cellpadding=”0″ cellspacing=”1″ bgcolor=”#e9e9e9″ style=”padding:4px;”>
<tr>
<td  id=”table_title”  height=”25″>
<form id=”form1″ name=”form1″ method=”post” action=””>
<select name=”checkselect” id=”checkselect” onChange=”showdomain();”>
<option value=”0″ selected >请选择</option>
<option value=”all”>所有站(seo+支撑站)</option>
<?php foreach($showtypename[1] as $typename){ ?>
<option value=”<?php echo $typename[‘id’]?>”><?php echo $typename[‘typename’]?></option>
<?php }?>
</select>
<br/>
<br/>
<textarea name=”textarea” id=”textarea” cols=”45″ rows=”5″></textarea><br/>
<input type=”button” name=”button” id=”button” value=”提交” onclick=”return ccshow(”);” />
<div id=”sfnum”></div>
<div id=”sfnum_end”></div>
<div id=”status”></div>
</form>
<div id=’fachild’></div>
</td>
</tr>
</table>

</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan=”3″>&nbsp;</td>
</tr>
</table>
<!– 第一个表格结束 –>

 

<br><br><br>

<!– 正文中更多内容开始 –>
<!– 标题部分 –>

<!– 内容部分 –>

</td>
<td background=”/images/images1/c_16.jpg”></td>
</tr>
<!– 第2个tr结束–>

<!– 第3个tr开始–>
<tr>
<td><img src=”/images/images1/c_20.jpg” width=”7″ height=”7″ /></td>
<td background=”/images/images1/c_22.jpg”></td>
<td><img src=”/images/images1/c_24.jpg” width=”7″ height=”7″ /></td>
</tr>
<!– 第3个tr结束–>
</table>
</body>
</html>
<script>
//函数注释写在函数上面,普通注释写在相应的右侧。
var table , tbody;

//创建表格
function createtab(){
table = document.createElement(“table”);
//table.setAttribute(“id”,”table22″);
table.setAttribute(“border”,”0″);
//table.setAttribute(“width”,”500″); //width=”100%” border=”0″ cellpadding=”0″ cellspacing=”1″ bgcolor=”#e9e9e9″
table.setAttribute(“cellPadding”,”0″);
table.setAttribute(“cellSpacing”,”1″);
table.setAttribute(“bgColor”,”#e9e9e9″);
tbody = document.createElement(“tbody”);
table.appendChild(tbody);
document.getElementById(‘fachild’).appendChild(table);
}

//创建tr,td
function createtr(str,domain){

var domain=”<a href=’http://”+domain+”‘ target=’_blank’>”+domain+”</a>”;
//table.setAttribute(“border”,”1″);
var tr1 = document.createElement(“tr”);

var td3 = document.createElement(“td”);
$(td3).html(table.rows.length+1);
tr1.appendChild(td3);

var td1 = document.createElement(“td”);
$(td1).html(domain);
tr1.appendChild(td1);

var td2 = document.createElement(“td”);
$(td2).html(str);
tr1.appendChild(td2);
 

td1.setAttribute(“id”,”table_title1″);
td2.setAttribute(“id”,”table_title2″);
td3.setAttribute(“id”,”table_title3″);

td1.setAttribute(“width”,”400″);
td2.setAttribute(“width”,”300″);
td3.setAttribute(“width”,”100″);

tbody.appendChild(tr1);
return td2;

}

//除去空格
String.prototype.Trim = function(){
return this.replace(/(^\s*)|(\s*$)/g, “”);
}

//js删除表格 ————-暂不使用
/*
function deltable(tabname){
var table = document.getElementById(tabname);
for(var i=0; i<table.rows.length; i++){
table.deleteRow(i);
}
}
*/

//结束删除表格
/* 这个火狐下不兼容,就不用了
function delobj(obj){
if(!obj){
alert(obj);
return;
}
obj.innerHTML=”;
//obj.removeNode(true);
//obj=null;
//delete obj;
CollectGarbage();
}
*/
//获得需要执行的域名-根据选择的类型显示的
function showdomain(){
var checkselect=document.getElementById(“checkselect”).value;
$.ajax({
type: “POST”,
dataType: “json”,//这里返回的格式是json格式。
url: “index.php?c=checkSessionController&a=doshowdomain”,
data: {//传过去的post数据,这里格式是对象格式,比传统写法更严禁,如:&字符过滤。
“id”:checkselect,
“ajaxSend”:1 //这个是给框架设计用的,用了让框架知道是ajax提过来的。目的是能区别错误返回页面(错误提示!–框架中的)
},
error:_ajaxRetrunErrFunction ,//若出现返回数据的异常,被这个函数捕捉。
success: function(myjson){
//if(_ajaxReturnFunction(myjson)==true){//_ajaxReturnFunction是对返回的数据进行预处理,若返回的数据是json格式并且返回值==OK或返回的第一个键值==OK,则这个函数会弹出一个默认的说明以提示操作成功并返回值为真,否则就是提示操作失败,返回值为假。
//}
var textarea_value=””;
for(var i=0;i<myjson.length;i++){
textarea_value+=myjson[i].ftp_domain+”\r”;
}
$(“textarea”).text(textarea_value);
$(“#sfnum”).text(“需要执行站个数:”+myjson.length);
}
});
}

page_num=1;
allnum=0;
nownum=0;
//点击提交按钮的时候要执行的(返回值,回写表格)。
function ccshow(a){
document.getElementById(“button”).disabled=true;
document.getElementById(“status”).innerHTML=”<br/><font color=blue>状态:执行中……</font>”;

page_num=1;//重新初始化
nownum=0;
//document.getElementById(‘fachild’).innerHTML=”;
createtab();//为div再次添加表格
checkshow(a);
}

function checkshow(abc){
if(abc!=”){page_num++;}//让执行的页数加1;
// delobj(document.getElementById(‘fachild’));//清除div内容 ,这个火狐下不兼容,就不用了。
var textarea=document.getElementById(“textarea”).value;
textarea= textarea.Trim();
var checkselect=document.getElementById(“checkselect”).value;
if(textarea==””&&checkselect==”0″){
alert(“请选择类型或输入域名”);
return false;
}
var arrdomain=textarea.split(“\n”);

//定义分批
var onepagenum=10;//定义每次执行的数目;
var begain_i=(page_num-1)*onepagenum;
var pagecount=Math.ceil(arrdomain.length/onepagenum);//总个数除以每页要执行的==需要执行多少批。
var end_i=eval(begain_i)+eval(onepagenum);
var yu=arrdomain.length-begain_i;
if(yu<onepagenum){end_i=eval(begain_i)+eval(yu);}
var a=0; //初始化a,用来判断当前页是否执行完毕的。
//document.getElementById(“sfnum_end”).innerHTML=”1/”+pagecount+”批”;//初始化定义开始显示第一页

for(var i=begain_i;i<end_i;i++){
var adomain=arrdomain[i];
//var adomainstr=”<a href=’http://”+arrdomain[i]+”‘ target=’_blank’>”+arrdomain[i]+”</a>”;
var str=”&nbsp;<font color=red>系统运行结果……</font><br/>”;
if(page_num<=pagecount){

var mytd=createtr(str,adomain);
$.ajax({
type: “POST”,
url: “index.php?c=checkSessionController&a=doCheckSession”,
//cache: false,
// async: false,//默认是true异步操作,若async:false就是同步操作,
context: mytd,//这个参数是为了上下文对象用的,若这里定义了它(mytd)则在后面返回值中可以用$(this)指代mytd这个对象。
data: {
“domain”:adomain
// “nownum”:(i+1),
//”countnum”:arrdomain.length
},

success: function(msg){
$(this).html(msg);
allnum=allnum+1;
nownum=nownum+1;
//alert(allnum);
$(“#sfnum_end”).html(“<br/>已执行”+allnum+”/–当前执行比例:”+nownum+”/”+arrdomain.length);
if(++a==onepagenum){//若当前批都执行完了,就执行下一批。
checkshow(“yes”);
}
if(nownum==arrdomain.length){
document.getElementById(“status”).innerHTML=”<br/><font color=red>状态:完成</font>”;
document.getElementById(“button”).disabled=false;
}
}
});//结束ajax
}
}//结束for

}

</script>


关注公众号,了解更多it技术(it问答网

基于PHP的cURL快速入门

cURL 是一个利用URL语法规定来传输文件和数据的工具,支持很多协议,如HTTP、FTP、TELNET等。最爽的是,PHP也支持 cURL 库。本文将介绍 cURL 的一些高级特性,以及在PHP中如何运用它。

为什么要用 cURL?

是的,我们可以通过其他办法获取网页内容。大多数时候,我因为想偷懒,都直接用简单的PHP函数:

以下为引用的内容:

$content = file_get_contents(“http://www.nettuts.com”);
// or
$lines = file(“http://www.nettuts.com”);
// or
readfile(http://www.nettuts.com);

不过,这种做法缺乏灵活性和有效的错误处理。而且,你也不能用它完成一些高难度任务——比如处理coockies、验证、表单提交、文件上传等等。

引用:
cURL 是一种功能强大的库,支持很多不同的协议、选项,能提供 URL 请求相关的各种细节信息。

基本结构

在学习更为复杂的功能之前,先来看一下在PHP中建立cURL请求的基本步骤:

初始化 设置变量 执行并获取结果 释放cURL句柄

以下为引用的内容:

// 1. 初始化
$ch = curl_init();
// 2. 设置选项,包括URL
curl_setopt($ch, CURLOPT_URL, “http://www.nettuts.com”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
// 3. 执行并获取HTML文档内容
$output = curl_exec($ch);
// 4. 释放curl句柄
curl_close($ch);

第二步(也就是 curl_setopt() )最为重要,一切玄妙均在此。有一长串cURL参数可供设置,它们能指定URL请求的各个细节。要一次性全部看完并理解可能比较困难,所以今天我们只试一下那些更常用也更有用的选项。

检查错误

你可以加一段检查错误的语句(虽然这并不是必需的):

以下为引用的内容:

// …
$output = curl_exec($ch);
if ($output === FALSE) {
echo “cURL Error: ” . curl_error($ch);
}
// …

请注意,比较的时候我们用的是“=== FALSE”,而非“== FALSE”。因为我们得区分 空输出 和 布尔值FALSE,后者才是真正的错误。

 


关注公众号,了解更多it技术(it问答网

经典,完美抓取页面程序原理

<?php
/*
描述:从0a上抓取站点信息
作者:xuduowei
日期:2011.02.12
*/
class getInfoController extends tcoaBaseController{

protected $getInfoModel;
public function set_getInfoModel($getInfoModel){
$this->getInfoModel=$getInfoModel;
}
//载入checkSessionModel模型,方便后面调用里面的方法,如:域名列表显示
protected $checkSessionModel;
public function set_checkSessionModel($checkSessionModel){
$this->checkSessionModel=$checkSessionModel;
}

//jquery调用方法
public function getInfo(){
$domain=trim($_POST[‘domain’]);
$domainarr=$this->getInfoModel->listsite($domain);
$old_timeout=ini_get(‘default_socket_timeout’);
ini_set(‘default_socket_timeout’,15); //设置file_get_contents 取值超时,当前是15秒

foreach($domainarr as $domainname){
$ftpdomain=$domainname[‘ftp_domain’];
$siteipold=$domainname[‘siteip’];
$ftp_userold=$domainname[‘ftp_user’];
$ftp_passold=$domainname[‘ftp_pass’];
$db_hostold=$domainname[‘db_host’];
$db_userold=$domainname[‘db_user’];
$db_passold=$domainname[‘db_pass’];
$serveripold=$domainname[‘serverip’];

$domainarr=explode(“www.”,$ftpdomain);
$begainurl=Project::singleton()->getConfig(‘customConfig.getInterfaceURL’);//其中getInterfaceURL为tcoaBaseController中的一个自定义变量(接口路径)。
$url=$begainurl.$domainarr[1];

$jsoncon=””;
$i=0;
if(function_exists(“file_get_contents”)){
while($i<3&&empty($jsoncon)){
$i++;
$jsoncon=file_get_contents($url);
}
}elseif(function_exists(‘curl_init’)){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$jsoncon = curl_exec ($ch);
curl_close ($ch);
}
if(!empty($jsoncon)){
// $jsoncon=file_get_contents($url);//若直接这样写的话,不是很完美。参看行28-39
$ans = json_decode($jsoncon,true);
$siteip=$ans[“ip”];
$ftpuser=$ans[“ftpuser”];
$ftppwd=$ans[“ftppwd”];

$dbuser=$ans[“dbuser”];
$dbpwd=$ans[“dbpwd”];
$db=$ans[“db”];
$siteip2=$siteip;
$serverip=$ans[“server”];
//从oa上获得信息后,按域名更新相应的信息。
$this->getInfoModel->updateinfo($siteip2,$ftpuser,$ftppwd,$siteip2,$dbuser,$dbpwd,$db,$serverip,$ftpdomain);
if(!empty($ftpdomain)){
if($siteipold==$siteip){
$str.=”成功更改:”.$ftpdomain.”–原子站ip:”.$siteipold.”–<font color=red>更改后:”.$siteip.”</font><br/>”;
$str.=”成功更改:”.$ftpdomain.”–原ftp用户名:”.$ftp_userold.”–<font color=red>更改后:”.$ftpuser.”</font><br/>”;
$str.=”成功更改:”.$ftpdomain.”–原ftp密码:”.$ftp_passold.”–<font color=red>更改后:”.$ftppwd.”</font><br/>”;
$str.=”成功更改:”.$ftpdomain.”–原数据库用户名:”.$db_userold.”–<font color=red>更改后:”.$dbuser.”</font><br/>”;
$str.=”成功更改:”.$ftpdomain.”–原数据库密码:”.$db_passold.”–<font color=red>更改后:”.$dbpwd.”</font><br/>”;
$str.=”成功更改:”.$ftpdomain.”–原服务器ip:”.$serveripold.”–<font color=red>更改后:”.$serverip.”</font><br/>”;
echo $str;
}else{
$str.=”成功更改:”.$ftpdomain.”–原子站ip:<font color=blue>”.$siteipold.”</font>–<font color=red>更改后:”.$siteip.”</font><br/>”;
$str.=”成功更改:”.$ftpdomain.”–原ftp用户名:<font color=blue>”.$ftp_userold.”</font>–<font color=red>更改后:”.$ftpuser.”</font><br/>”;
$str.=”成功更改:”.$ftpdomain.”–原ftp密码:<font color=blue>”.$ftp_passold.”</font>–<font color=red>更改后:”.$ftppwd.”</font><br/>”;
$str.=”成功更改:”.$ftpdomain.”–原数据库用户名:<font color=blue>”.$db_userold.”</font>–<font color=red>更改后:”.$dbuser.”</font><br/>”;
$str.=”成功更改:”.$ftpdomain.”–原数据库密码:<font color=blue>”.$db_passold.”</font>–<font color=red>更改后:”.$dbpwd.”</font><br/>”;
$str.=”成功更改:”.$ftpdomain.”–原服务器ip:<font color=blue>”.$serveripold.”</font>–<font color=red>更改后:”.$serverip.”</font><br/>”;
echo $str;
}
}
}else{
$str=”<font color=red>更改失败!!!!!!!</font>”.$ftpdomain.”–原ip:”.$siteipold.”<br/>”;
echo $str;
}
if(!empty($ftpdomain)){
$this->insertLog($ftpdomain,$str);
}
}//结束foreach
ini_set(‘default_socket_timeout’,$old_timeout);
}//结束function

//视图方法
public function showGetInfo(){
$this->getInfo();
$View=ViewDepository::singleton()->imLoad(‘./tcoaView/getInfoView.php’);
$View->showtypename=$this->checkSessionModel->listtypename();
echo $View->render();
}

//写日志方法
public function insertLog($domain,$str){
$time=time();
$group_id= $this->userName.”_”.date(“YnjHis”);
//$tj=” group_id=’$group_id’,domain=’$domain’,description=’$str’,checktime=’$time'”;
$arrdomain=$this->getInfoModel->insertlog($group_id,$domain,$str,$time);
}
}
?>


关注公众号,了解更多it技术(it问答网

MySQL查询及删除重复记录的方法

查询及删除重复记录的方法
(一)
1、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断

select * from people where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)

2、删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录

delete from people where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1) and rowid not in (select min(rowid) from people group by peopleId having count(peopleId )>1)

3、查找表中多余的重复记录(多个字段)

select * from vitae a where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)

4、删除表中多余的重复记录(多个字段),只留有rowid最小的记录

delete from vitae a where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1) and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)

5、查找表中多余的重复记录(多个字段),不包含rowid最小的记录

select * from vitae a where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1) and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)

(二)
比方说
在A表中存在一个字段“name”,
而且不同记录之间的“name”值有可能会相同,
现在就是需要查询出在该表中的各记录之间,“name”值存在重复的项;

Select Name,Count(*) From A Group By Name Having Count(*) > 1

如果还查性别也相同大则如下:

Select Name,sex,Count(*) From A Group By Name,sex Having Count(*) > 1

(三)
方法一

declare @max integer,@id integer

declare cur_rows cursor local for select 主字段,count(*) from 表名 group by 主字段 having count(*) >; 1

open cur_rows

fetch cur_rows into @id,@max

while @@fetch_status=0

begin

select @max = @max -1

set rowcount @max

delete from 表名 where 主字段 = @id

fetch cur_rows into @id,@max

end

close cur_rows

set rowcount 0

方法二

有两个意义上的重复记录,一是完全重复的记录,也即所有字段均重复的记录,二是部分关键字段重复的记录,比如Name字段重复,而其他字段不一定重复或都重复可以忽略。

1、对于第一种重复,比较容易解决,使用

select distinct * from tableName

就可以得到无重复记录的结果集。

如果该表需要删除重复的记录(重复记录保留1条),可以按以下方法删除

select distinct * into #Tmp from tableName

drop table tableName

select * into tableName from #Tmp

drop table #Tmp

发生这种重复的原因是表设计不周产生的,增加唯一索引列即可解决。

2、这类重复问题通常要求保留重复记录中的第一条记录,操作方法如下

假设有重复的字段为Name,Address,要求得到这两个字段唯一的结果集

select identity(int,1,1) as autoID, * into #Tmp from tableName

select min(autoID) as autoID into #Tmp2 from #Tmp group by Name,autoID

select * from #Tmp where autoID in(select autoID from #tmp2)

最后一个select即得到了Name,Address不重复的结果集(但多了一个autoID字段,实际写时可以写在select子句中省去此列)

(四)
查询重复

select * from tablename where id in (select id from tablename group by idhaving count(id) > 1);


关注公众号,了解更多it技术(it问答网

ecshop页面纯静态生成方法

ECSHOP是一套非常不错的开源网站程序,本身的优化也做得不错,不过很多东西都是动态的,如果简单的生成伪静态,很有可能会造成多种URL同时存在,LEO从网上找了下ECSHOP生成纯静态(HTML)的方法,先给大家贴出来,抽时间试验下!

1.复制首页index.php为index_html.php,因为ECSHOP是使用SMARTY模板引擎的,所以我们可以使用SMARTY生成文件函数,把模板的静态网页输出。

在首页中,$smarty->display(‘index.dwt’, $cache_id);有这一句,说明是把网页显示出来,现在我们把它改成如下代码(参看注释)
$file = ‘index.html’;//静态网页文件名
$content = $GLOBALS[‘smarty’]->make_html(‘index.dwt’);//根据index.dwt模板生成网页内容
$filename = ROOT_PATH . $file;//静态网页路径
file_put_contents($filename, $content);//生成文件

以上几条简单的语句,我们就可以生成首页的静态网页。同理,我们可以生成产品类别和产品的静态网页,整个系统的静态化就完成了。


关注公众号,了解更多it技术(it问答网

桌面上的快速启动没有了

如果快速启动栏里面的“显示桌面”被误删或消失了!只要新建个文本文档输入一下内容

[Shell]

Command=2

IconFile=explorer.exe,3

[Taskbar]

Command=ToggleDesktop

 

在新建文档中选择“文件”菜单—“另存为……”—文件类型选择为“所有文件”—文件名为“显示桌面.SCF”—成功啦!

小技巧:在“IconFile=explorer.exe,3”里面的“3”改为“4”就变成打印机的图表,因此只要把“3”这个位置的数字替换为相应的数字便可达到更换图表的效果!


关注公众号,了解更多it技术(it问答网