Prev | Current Page 332 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

..')) AS description,
price, discounted_price, thumbnail
FROM product
WHERE MATCH (name, description) AGAINST (?)
ORDER BY MATCH (name, description) AGAINST (?) DESC
LIMIT ?, ?";
END IF;
SET @p1 = inShortProductDescriptionLength;
SET @p2 = inSearchString;
SET @p3 = inStartItem;
SET @p4 = inProductsPerPage;
EXECUTE statement USING @p1, @p1, @p2, @p2, @p3, @p4;
END$$
How It Works: The Catalog Search Functionality
In this exercise, you created the database functionality that supports the product-searching business tier logic,
which consists of two stored procedures:
??? catalog_count_search_result: This stored procedure counts the number of search results. This is
required so that the presentation tier will know how many search results pages to display.
??? catalog_search: This stored procedure performs the actual product search.
Although they can look intimidating at first, mostly because of their size, these stored procedures simply put the
full-text search theory you learned earlier in this chapter to good use. Additionally, catalog_search implements
the paging techniques that are also present in the other procedures that return lists of products.
Implementing the Business Tier
The business tier of the search feature consists of a single method named Search, which calls
the two stored procedures you implemented earlier to retrieve the list of searched products.


Pages:
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344