MySQL Query: how does MATCH work with PDO?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

MySQL Query: how does MATCH work with PDO?

Post by simonmlewis »

We are having a few problems with our search results on web site.

For example, if you was looking for a shirt, and it was titled "White Shirt Brand", but you searched for "white shirt black collar", it would not find that product, because the title isn't what you searched on.

I'm use there use to be a good way to find it, so that the words "white" and "shirt" were in the criteria and it found it.

How does this work with PDO queries?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: MySQL Query: how does MATCH work with PDO?

Post by requinix »

Have you tried MATCH...AGAINST with some real queries? It might not behave quite how you want it to.

Anyway, there's nothing special about it with PDO. Prepared statement, plain query, it works just... normally.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: MySQL Query: how does MATCH work with PDO?

Post by simonmlewis »

I've tried "...OR MATCH(title) AGAINST (:search).
It works. Does give results that are not relevant, but if either word is in the title, it comes up, so I suppose it's bringing up the "correct" results.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: MySQL Query: how does MATCH work with PDO?

Post by requinix »

It also tends to ignore words when a majority of rows contain it. Like if most said "Something Brand" then "Brand" in a search term would be ignored. But that may be desirable for you.
Post Reply