5

Summary

Development of the database objects and PHPServer-side scripting language for web development. classes to support site search functionality.

Overview

PurposeTo add search capabilities to web site.
Goals
  • Collect statistics on the occurrence of words in the pages of the site.
  • Allow user to search the website for keywords by querying these statistics.
  • Display result in order of relevance determine by the prevalence of the keywords.
TechnologyNo new additions to environment.
ResourcesNone

Implementation

  1. Create Database Objects

    The implementation of the below objects was done using PhinxA PHP library to automate the implementation of database changes. in a new migration created for this project.

    • FACT_SEARCH - is a table was created to hold all the unique words in each page and the number of times each word appeared on the page.
    • SEARCH_PURGE - a procedure that deletes all the rows in the Search table.
    • SEARCH_INSERT - a procedure responsible for inserting records into the Search table.
  2. Create \ Modify Controller Classes

    • App/Controllers/Support/Utility.php - This class was modified to add three methods related the manipulation of multi-dimensional arrays.
    • App/Controllers/Search.php - This class was created to manage the loading of the statistics data to FACT_SEARCH as wells as controlling the behavior of search requests.
  3. Create Model Class

    App/Models/Search.php - was created to interact directly with the FACT_SEARCH table allowing it to be reloaded and queried.

  4. Create \ Modify View Files

    • App/Views/Search/index.html - was created to display the search form and results of the search.
    • App/Views/Admin/index.html - was modified to make the Search statistics reload method available via the site to admin users.
    • App/Views/base.html - was modified to make the search option available on all pages from the navigation bar.
  5. Add Search Controller to Dependency Injection Pattern

    • public/index.php - modified to instantiate s shared Search Controller object which is injected into the Router.
    • Core/Router.php - the constructor was modified to accept the Search object and pass it into Controller classes.
    • Core/Controller.php - the constructor was modified to accept the Search object.
  6. Populate Search Statistics

    Login as admin and execute the Search load process from the Admin page.