|
发表于 2011-2-27 18:55:33
|
显示全部楼层
- CREATE TABLE IF NOT EXISTS `ve123_links` (
- `link_id` mediumint(9) NOT NULL auto_increment,
- `title` varchar(225) NOT NULL,
- `tuiguang` int(11) NOT NULL,
- `site_id` mediumint(9) NOT NULL,
- `url` varchar(325) NOT NULL,
- `keywords` mediumtext NOT NULL,
- `description` mediumtext NOT NULL,
- `fulltxt` mediumtext NOT NULL,
- `pagesize` float NOT NULL,
- `level` int(11) NOT NULL,
- `addtime` int(11) NOT NULL,
- `updatetime` int(11) NOT NULL,
- `lrymd5` varchar(32) NOT NULL,
- PRIMARY KEY (`link_id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=gbk AUTO_INCREMENT=1 ;
复制代码- function q($wd,$domain='')
- {
- global $db;
- $this->db = &$db;
- $this->wd=$wd;
- require "../include/splitword.func.php";
- $sp = new SplitWord();
- $wd_split = $sp->SplitRMM($wd);
- $sp->Clear();
- $this->wd_split=$wd_split = ereg_replace("[ ]{1,}"," ",trim($wd_split));
- $this->wd_array=$wd_array=explode(" ",$wd_split);
- $this->wd_count=$wd_count=count($wd_split);//echo $wd_count;
- $tgarray=$this->GetTg();
- $tgarray_count=count($tgarray);
- $ordersql=" order by links.tuiguang desc,(";
- foreach($wd_array as $value)
- {
- $ordersql.="(case when links.title like '%".$value."%' then 1 else 0 end)+";
- }
-
- $ordersql.="(case when links.title like '%".$wd."%' then 8 else 0 end)";
- // $ordersql=rtrim($ordersql,"+");
- $ordersql.=") desc";
- $keywordsql=$this->GetKeywordSql("links.title,' ',links.url");
- if(empty($keywordsql))
- {
- $keywordsql="links.title like '%".$wd."%'";
- }
- if(empty($domain))
- {
- $sql="select links.*,sites.qp from ve123_links links left join ve123_sites sites on links.site_id=sites.site_id where links.title<>'' and ".$keywordsql.$ordersql;
- }
- else
- {
- if($domain==getdomain($domain))
- {
- $sql="select * from ve123_links where title<>'' and url like '%.".$domain."%' or url like '%//".$domain."%'"; //echo $sql;
- }
- else
- {
- $sql="select * from ve123_links where title<>'' and url regexp 'http://".$domain."'";//echo $sql;
- }
- }
- //echo $sql;
- $query=$db->query($sql);
- $this->total=$total=$db->num_rows($query)+$tgarray_count;
- $pagesize=10;
- $this->totalpage=$totalpage=ceil($total/$pagesize);
- $p=intval($_GET["p"]);
- if($p<=0){$p=1;}
- $offset=($p-1)*$pagesize;
- $query=$db->query($sql." limit $offset,$pagesize");
- while($row=$db->fetch_array($query))
- {
- $data["title"]=$this->GetRedKeyWord(str_cut($row["title"],50));
- if(!$row["description"])$row["description"] = $row["fulltxt"];
- $data["txt"]=$this->GetRedKeyWord(str_cut($row["description"],250));
- $data["url"]=str_cut($row["url"],400);
- $data["updatetime"]=date("Y-m-d",$row["updatetime"]);
- $data["pagesize"]=$row["pagesize"];
- $data["link_id"]=$row["link_id"];
- $data["tuiguang"]=$row["tuiguang"];
- $array[] = $data;
- }
-
- $array_count=count($array);
- if(empty($array_count))
- {
- $newarray=$tgarray;
- }
- elseif($p==1&&$tgarray_count>0)
- {
- $newarray=array_merge($tgarray,$array);
- }
- else
- {
- $newarray=$array;
- }
- return $newarray;
- }
复制代码 基于mysql like和联表的查询,表连myisam的fulltext索引都不加,用这东西会死人的......
[ 本帖最后由 Kokgog 于 2011-2-27 18:56 编辑 ] |
评分
-
查看全部评分
|