Database Articles
  Home arrow Database Articles arrow Page 10 - Creating a Search Application
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DATABASE ARTICLES

Creating a Search Application
By: Matt Wade
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 14
    2003-07-15

    Table of Contents:
  • Creating a Search Application
  • Database Usage
  • Creating a Search Application
  • Searching
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Creating a Search Application -


    (Page 10 of 29 )

    To gather keywords for our search application, we will provide a simple form that will accept the URLs of the websites to be searched. This will be effective for small sites where all the URLs are known. Large sites with dynamic URLs would be better served by a spider script. Writing an effective spider is well beyond the scope of this document and will be left for an exercise to the reader. For reference, you might want to look at the PHPDig project as they have nice spider built into their application.

    The harvest.php script itself will not have much PHP code in it. The reason for this is that the code to perform the harvesting functions will be in a class that is stored in a file named harvestclass.php. Let's take a high level overview of the Harvest_Keywords class and then we will examine each function in detail.

  • Declare class variables - The first order of business in the class is to declare the variables that will be used to store information that will be shared throughout the class.
  • Constructor - The constructor of this class will first establish a database connection utilizing the database class we created earlier. Then it will store, as an array, the URL(s) that were entered.
  • _prune - This function is a private function of the class. A private function is one that is not called from outside the class. PHP does not provide a way to truly make a function private, but we will precede any function we deem to be private with an underscore. This just serves to document them as private for our later reference. We will use this function in conjunction with the array_walk function of PHP to remove unwanted words from the keywords we gather.
  • _checkURL - Also a private function, this will run a perform a very basic validation of a URL.
  • _getData - We will use this private function to take care of the details of opening a connection to a URL and obtaining the source.
  • _harvest - This function is where the real work is done. This private function will call the other functions of this class to gather all the keywords from a single URL and store them in a database.
  • process - This function is will iterate through each URL provided to it and call the _harvest function to gather keywords.

    More Database Articles Articles
    More By Matt Wade


       · 
       · I've copy and paste the five files regarded in this tutorial, and created the db,...
       · Hello,


    'id' INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,

    I'm...
       · THANKS - MATTVery clear explained tutorial.Wonderful search, I am...
       · My phpadmin had no issues with the table creation, but can't get the harvest script...
       · It's an ok search tutorial, but too many errors.[QUOTE]Warning: array_walk()...
       · Where to post for help on this tutorial?CheersWest
       · great tutorial and very inspiring column in your conclusion.
     

  • DATABASE ARTICLES ARTICLES

    - More on Query Optimization for Oracle Databa...
    - Query Optimization in Oracle
    - Clusters and Other Data Structures for Oracle
    - Using Indexes with an Oracle Database
    - The Basics of Data Structures in Oracle
    - Oracle Data Structures
    - Best Practices for PL/SQL Variables
    - What`s Code Without Variables?
    - Clauses, Sorting, and SQL Queries
    - The From Clause and SQL Queries
    - Query Primer
    - Full Text Searches and Strings
    - Searching with Strings
    - Pattern Matching with Strings
    - Working with Cases of Strings





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    Stay green...Green IT