background preloader

MYSQL

Facebook Twitter

Multiple Column Text Search of MySQL Database Using PHP. I have done this a few times but I can never quite remember how it works. Thanks to some assistance from Sheldon I was able to put together this simple tutorial on how to create a PHP search that will automatically search multiple MySQL columns, score the results, and return the results ordered by relevance. This goes a step beyond a simple LIKE search and uses MySQL FULLTEXT indexing for more accurate results.

Basically, the system works by creating a joint FULLTEXT index on the columns that need to be searched. This can be done either using PHP to execute a simple MySQL query or it can be done through phpMyAdmin by executing a query similar to the following: (NOTE: This example assumes the column names for the search are title and content. Once the above query has been executed you should now have FULLTEXT indexing on the columns title and content. Good luck! Solving PHP MySQL UTF-8 issues. Developers Need to Index. SQL performance problems are as old as SQL itself—some might even say that SQL is inherently slow. Although this might have been true in the early days of SQL, it is definitely not true anymore. Nevertheless SQL performance problems are still commonplace. How does this happen? The SQL language is perhaps the most successful fourth-generation programming language (4GL). Its main benefit is the capability to separate “what” and “how”.

An SQL statement is a straight description what is needed without instructions as to how to get it done. SELECT date_of_birth FROM employees WHERE last_name = 'WINAND' The SQL query reads like an English sentence that explains the requested data. The separation of concerns—what is needed versus how to get it—works remarkably well in SQL, but it is still not perfect. It turns out that the only thing developers need to learn is how to index. This book covers everything developers need to know about indexes—and nothing more. CHAPTER 1 - Anatomy of an Index. Using MySQL Full-text Searching. Intended AudienceOverviewLearning ObjectivesDefinitionsBackground InformationPrerequisitesSynopsis Initial IdeasThe Solution: SetupThe Solution: Actually Doing SomethingMore about Basic SearchingExample: Basic Searching ApplicationAdvanced Boolean SearchingBoolean: The Basic Technical AspectA Basic Boolean Searching ApplicationResources About The Author: Intended Audience This tutorial is intended for developers using MySQL ( and PHP ( who want to create a searchable database of some sort of textual data.

It will focus on the Full-text capabilities presented by MySQL, moving into the Boolean opportunities that are presented in the latest alpha version, 4.1, of MySQL. Overview Using directories to group articles by category is a great way to help people to navigate through many articles. Learning Objectives Definitions MySQL – An Open Source database that is used by many PHP developers for it’s support and speed, as well as because it’s free. Synopsis <? Backup Your MySQL Database Using PHP. One of the most important tasks any developer needs to do often is back up their MySQL database. In many cases, the database is what drives most of the site. While most web hosts do a daily backup of a customer's database, relying on them to make backups and provide them at no cost is risky to say the least. That's why I've created a database backup function that I can call whenever I want -- including nightly CRONs.

The PHP & MySQL Code Of course, you'll need to provide database credentials to the function, as well as an array of tables you'd like to backup. Never take chances when your website is on the line. Be Heard Tip: Wrap your code in <pre> tags or link to a GitHub Gist! Older Same Site, New Theme Newer PHP / MooTools 1.2 Accordion Helper.