PHPackages                             yarri/full-text-search-query-like - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. yarri/full-text-search-query-like

ActiveLibrary[Database &amp; ORM](/categories/database)

yarri/full-text-search-query-like
=================================

FullTextSearchQueryLike is a PHP class which transforms search strings into clever SQL conditions with the LIKE operator

v0.2(7y ago)436.3k↑45%1MITPHPPHP &gt;=5.3.0

Since Feb 2Pushed 2y ago1 watchersCompare

[ Source](https://github.com/yarri/FullTextSearchQueryLike)[ Packagist](https://packagist.org/packages/yarri/full-text-search-query-like)[ Docs](https://github.com/atk14/FullTextSearchQueryLike)[ RSS](/packages/yarri-full-text-search-query-like/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (4)Used By (1)

FullTextSearchQueryLike
=======================

[](#fulltextsearchquerylike)

[![Build Status](https://camo.githubusercontent.com/5cadab39a0471fd5c9e360eeea473cd64ce00213f55845c765c434cbf9f4e869/68747470733a2f2f6170702e7472617669732d63692e636f6d2f79617272692f46756c6c5465787453656172636851756572794c696b652e7376673f6272616e63683d6d6173746572)](https://app.travis-ci.com/yarri/FullTextSearchQueryLike)[![Downloads](https://camo.githubusercontent.com/9a7722654a44799689f89e331d2368f64a9bd930703d77ed3b1ca56825afd7d5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f79617272692f66756c6c2d746578742d7365617263682d71756572792d6c696b652e737667)](https://packagist.org/packages/yarri/full-text-search-query-like)

A PHP class which transforms search strings into clever SQL conditions with the LIKE operator.

The FullTextSearchQueryLike is fully tested in PHP from version 5.6 to 8.1.

Basic usage
-----------

[](#basic-usage)

Consider a table articles with a field title in which we would like to let users search.

```
$q = $_GET["search"]; // Here comes a user query string, e.g. "beer and wine"

$ftsql = new FullTextSearchQueryLike("title");
if($ftsql->parse($q)){
  $search_condition = "WHERE ".$ftsql->get_formatted_query(); // e.g. "WHERE title LIKE '%beer%' AND title LIKE '%wine%'"
}

$query = "SELECT * FROM articles $search_condition ORDER BY created_at DESC";

```

Transformation examples
-----------------------

[](#transformation-examples)

Query stringFormatted querybeertitle LIKE '%beer%'beer burgertitle LIKE '%beer%' AND title LIKE '%burger%'beer and burgertitle LIKE '%beer%' AND title LIKE '%burger%'beer or burgertitle LIKE '%beer%' OR title LIKE '%burger%'beer not burgertitle LIKE '%beer%' AND NOT title LIKE '%burger%'+beer +burger -pizzatitle LIKE '%beer%' AND title LIKE '%burger%' AND NOT title LIKE '%pizza%'Some other specialities...

Query stringFormatted query'beer'title LIKE '%beer%'or' OR ''=''; DROP TABLE articles; --title LIKE '%DROP%' AND title LIKE '%TABLE%' AND title LIKE '%articles%' AND NOT title LIKE '%-%'Searching in more fields
------------------------

[](#searching-in-more-fields)

```
$q = $_GET["search"];

$ftsql = new FullTextSearchQueryLike("title||' '||body||' '||author");
// or
// $ftsql = new FullTextSearchQueryLike(["title","body","author"]);
if($ftsql->parse($q)){
  $search_condition = "WHERE ".$ftsql->get_formatted_query();
}

$query = "SELECT * FROM articles $search_condition ORDER BY created_at DESC";

```

Case insensitive searching
--------------------------

[](#case-insensitive-searching)

```
$q = $_GET["search"];

$ftsql = new FullTextSearchQueryLike("UPPER(title||' '||body||' '||author)");
if($ftsql->parse(strtoupper($q))){
  $search_condition = "WHERE ".$ftsql->get_formatted_query();
}

$query = "SELECT * FROM articles $search_condition ORDER BY created_at DESC";

```

Variable bindings
-----------------

[](#variable-bindings)

This is quite useful e.g. for Oracle database.

```
$q = $_GET["search"]; // Here comes a user query string, e.g. "beer and wine"

$ftsql = new FullTextSearchQueryLike("title");
if($ftsql->parse($q)){
  $bindings = [];
  $search_condition = "WHERE ".$ftsql->get_formatted_query_with_binds($bindings); // e.g. "WHERE title LIKE :search_word_021 AND title LIKE :search_word_022"
}

$query = "SELECT * FROM articles $search_condition ORDER BY created_at DESC";
var_dump($bindings); // e.g. [":search_word_021" => "%beer%", ":search_word_022" => "%wine%"]

```

Keywords highlighter
--------------------

[](#keywords-highlighter)

Don't forget to use my other tool for highlighting search words on a HTML output page.

Installation
------------

[](#installation)

Use the Composer to install the FullTextSearchQueryLike.

```
composer require yarri/full-text-search-query-like

```

Testing
-------

[](#testing)

In the package directory run:

```
composer update --dev
cd test
../vendor/bin/run_unit_tests

```

Final notice
------------

[](#final-notice)

Let's be honest. The code style is not great and all comments are in Czech language. The source was extracted from the very old project. But all the time it works well and reliably.

I really like it and install it to every new project i'm starting. It will be my pleasure when you find it useful too.

Licence
-------

[](#licence)

FullTextSearchQueryLike is free software distributed [under the terms of the MIT license](http://www.opensource.org/licenses/mit-license)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~413 days

Total

2

Last Release

2608d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6304dffbd91d7a978f98632b0e4e30d662dcdb691daadb1388a58984e98faf5c?d=identicon)[yarri](/maintainers/yarri)

---

Top Contributors

[![yarri](https://avatars.githubusercontent.com/u/974278?v=4)](https://github.com/yarri "yarri (47 commits)")

---

Tags

sqlfulltextlikefull-textLIKE operator

### Embed Badge

![Health badge](/badges/yarri-full-text-search-query-like/health.svg)

```
[![Health](https://phpackages.com/badges/yarri-full-text-search-query-like/health.svg)](https://phpackages.com/packages/yarri-full-text-search-query-like)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[doctrine/sql-formatter

a PHP SQL highlighting library

1.9k166.0M85](/packages/doctrine-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[phpmyadmin/sql-parser

A validating SQL lexer and parser with a focus on MySQL dialect.

47750.4M55](/packages/phpmyadmin-sql-parser)[ifsnop/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k5.5M69](/packages/ifsnop-mysqldump-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
