Prev | Current Page 325 | Next

Emilian Balanescu and Cristian Darie

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


Creating Data Structures That Enable Searching
In our scenario, the table that we??™ll use for searches is product, because that??™s what our visitors
will be looking for. Before you can make it searchable using FULLTEXT indexes, you need to make
sure its table type is MyISAM (this should be the case if you??™ve correctly followed the instructions
in the book). If you??™ve used any other table type when creating it, please convert it now
by executing this SQL statement after connecting to your tshirtshop database:
ALTER TABLE product ENGINE = MYISAM;
To make the product table searchable, we must add a full-text index on the (name, description)
pair of columns, as follows:
1. Load phpMyAdmin, select the tshirtshop database from the Database box, and click
the SQL tab.
2. In the form, type the following command, which adds a new full-text index named
idx_ft_product_name_description:
-- Create full-text search index
CREATE FULLTEXT INDEX `idx_ft_product_name_description`
ON `product` (`name`, `description`);
After clicking the Go button, you should be informed that the command executed
successfully.
Because we want TShirtShop to allow visitors to search for products that contain certain
words in their names or descriptions, we created a full-text index on the (name, description)
pair of fields of the product table (this is different than having two full-text indexes, one on
name and one on description).


Pages:
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
reklama internetowa Dyskusja Nr8 gitary przeprowadzki wrocław Betway Poker