teach you to do keyword matching project (search engine)----16th day, teach you to do----_php Tutorial

Source: Internet
Author: User

teach you to do keyword matching project (search engine)----16th day, teach you to do----


16th Day

Friendship cameo: The deceptive form artifact of the cock silk

Starting point: teach you to do keyword matching project (search engine)----first day

Review: Hand-taught you to do keyword matching project (search engine)----15th day

14 days PDF Version: http://files.cnblogs.com/oshine/%E6%89%8B%E6%8A%8A%E6%89%8B%E6%95%99%E4%BD%A0%E5%81%9A%E5%85%B3%E9%94% Ae%e8%af%8d%e5%8c%b9%e9%85%8d%e9%a1%b9%e7%9b%ae%2814%e5%a4%a9%29.pdf

Source code within 15 days:
Http://files.cnblogs.com/oshine/myproject.rar

Since the last small handsome with the eldest brother after the discussion, there is a very depressing thing has not been decided, is that we have a correspondence, antonyms and synonyms of the data format is what?

Little handsome to understand these can continue to go on, so he went to ask the boss.

Yullo to small handsome said, we first do not consider so many factors, we start from the actual, we first do the opposite this piece, first from the women's clothing is a category, we will start by category.

Then the table structure of the field has the category, antonym.

The little handsome created the table:

  CREATE   TABLE   ' category_backlist ' (' CID '   BIGINT  ( )  DEFAULT   NULL  COMMENT  '   category ID   '  , ' Catmatch '   VARCHAR  ( )  CHARACTER   SET  UTF8  DEFAULT   NULL  COMMENT  '   class name   '  , ' word '   VARCHAR  ()  Span>character   SET  UTF8  DEFAULT   NULL  COMMENT  '   keywords   '  , ' created '   DATETIME   DEFAULT   NULL  COMMENT span> '   entry time   '  ,   UNIQUE   KEY   ' cid ' (' CID ' , ' keyword ')) ENGINE   =  INNODB  DEFAULT  CHARSET  =  UTF8 COLLATE  =  Utf8_bin 

The little handsome and filled the data.

INSERT  into Category_backlist (cid,catmatch,word)VALUES("50010850", "ladies", "male"); INSERT  into Category_backlist (cid,catmatch,word)VALUES("50010850", "Ladies", "children"); INSERT  into Category_backlist (cid,catmatch,word)VALUES("50010850", "Ladies", "Baby"); ......

Small handsome very easy to the code also corrected a bit.

 PhpAbstract classCharlisthandle {protected $charlist; protected $selectorItem;  Public function__construct ($charlist,$selectorItem){        $this->charlist =$charlist; $this->selectoritem =$selectorItem; }    Abstract function exec();}classBacklistcharlisthandleextendsCharlisthandle { Public function exec(){        $sql= "Select Word from category_backlist where cid= '$this->selectoritem->cid ' "; $backlist= Db::makearray ($sql); foreach($backlist  as $char){            $this->charlist->addblacklist ($char); }    }}classselector{Private Static $charListHandle=Array(              "Blacklist" = "Backlistcharlisthandle"    );  Public Static functionSelect$num _iid)    {        $selectorItem= Selectoritem::createfromapi ($num _iid); Logger:: Trace ($selectorItem-props_name); $charlist=NewCharList (); foreach(Self::$charListHandle  as $matchKey=$className) {            $handle= Self::createcharlisthandle ($className,$charlist,$selectorItem); $handle-exec(); }        //Do search Things        Var_dump($charlist); }     Public Static functionCreatecharlisthandle ($className,$charlist,$selectorItem)    {        if(class_exists($className)) {            return New $className($charlist,$selectorItem); }        Throw New Exception("Class not exists", 0); }}

The manuscript of the small handsome originally was not so, his manuscript:

Charlisthandle properties There are two charlist one is the CID.

After looking at the eldest brother will be small handsome the CID replaced selectoritem, reason why small handsome to ponder.


The small handsome also wrote a DB operation class with the following code:

 PhpDefine(' Database_host ', ' 127.0.0.1 ');Define(' Database_user ', ' Xiaoshuaishuai ');Define(' Database__password ', ' Xiaoshuaishuai ');Define(' Database_charset ', ' utf-8 ');classDB { Public Static $conn=NULL;  Public Static functionConnect () {if(Self::$conn==NULL) { self::$conn=mysql_connect(Database_host,database_user,Database__password); mysql_query("SET NAMES".) Database_charset. "'", Self::$conn); mysql_select_db("Dict", Self::$conn); returnSelf::$conn; }        returnSelf::$conn; }         Public Static functionQuery ($sql){       return mysql_query($sql, Self::Connect ()); }         Public Static functionMakearray ($sql){        $rs= Self::query ($sql); $result=Array();  while($data=Mysql_fetch_assoc($rs)){            $result[] =$data; }        return $result; }} 

Small handsome This code to the eldest brother, in the boss very happy.

Yullo to small handsome said, now we this blacklist changes, no matter how you add or how to delete will not affect the normal operation of the system, and we can be very good with the business, this blacklist of the task, small handsome you think to teach who to do more appropriate.

Small handsome heard can transfer the task, very happy: to do these things, I think the product or Operation department is more appropriate.

In the eldest brother patted small handsome's shoulder said: This matter will be handed over to you to implement.

The occasional separation of duties is not necessarily an act of laziness, but, as a whole, makes the service more professional and efficient.

Little handsome had to go to the boss's mission.




http://www.bkjia.com/PHPjc/869242.html www.bkjia.com true http://www.bkjia.com/PHPjc/869242.html techarticle Hand -taught you to do keyword matching project (search engine)----16th day, teach you to do----16th Day Friendship Cameo: The deceptive form artifact starting point: Hands taught you to do keywords ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.