PHPackages                             ajur-media/fluentpdo - 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. ajur-media/fluentpdo

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

ajur-media/fluentpdo
====================

\[FORK\] FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

1.99.1(1y ago)0726Apache-2.0PHPPHP &gt;7.4 | 8.\*

Since Jan 25Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ajur-media/fluentpdo)[ Packagist](https://packagist.org/packages/ajur-media/fluentpdo)[ Docs](https://github.com/ajur-media/fluentpdo)[ RSS](/packages/ajur-media-fluentpdo/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (3)Versions (6)Used By (0)

FluentPDO [![Build Status](https://camo.githubusercontent.com/b64412308e1025f5d34685862b53c06ae00fa624e7a41b2e81b6846957fe8162/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f656e766d732f666c75656e7470646f2e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/envms/fluentpdo) [![Maintainability](https://camo.githubusercontent.com/74ddbdc6f119f1ad46ac6ddcc37de33d943d77e94418019281d6eb08fd5f346b/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f31393231306361393163373035356238393730352f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/fpdo/fluentpdo/maintainability)
=================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#fluentpdo--)

FluentPDO is a PHP SQL query builder using PDO. It's a quick and light library featuring a smart join builder, which automatically creates table joins for you.

Features
--------

[](#features)

- Easy interface for creating robust queries
- Supports any database compatible with PDO
- Ability to build complex SELECT, INSERT, UPDATE &amp; DELETE queries with little code
- Type hinting for magic methods with code completion in smart IDEs

Versions
--------

[](#versions)

#### Version 2.x

[](#version-2x)

The stable release of FluentPDO and actively maintained. Officially supports PHP 7.3 to PHP 8.0, but it can work with previous versions of PHP 7.

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

[](#installation)

### Composer

[](#composer)

Add the following line in your `composer.json` file:

```
"require": {
	...
	"ajur-media/fluentpdo": "^2.2.0"
}

```

update your dependencies with `composer update`, and you're done!

Getting Started
---------------

[](#getting-started)

Create a new PDO instance, and pass the instance to FluentPDO:

```
$pdo = new PDO('mysql:dbname=fluentdb', 'user', 'password');
$fluent = new \AJUR\FluentPDO\Query($pdo);
```

Then, creating queries is quick and easy:

```
$query = $fluent->from('comment')
             ->where('article.published_at > ?', $date)
             ->orderBy('published_at DESC')
             ->limit(5);
```

which would build the query below:

```
SELECT comment.*
FROM comment
LEFT JOIN article ON article.id = comment.article_id
WHERE article.published_at > ?
ORDER BY article.published_at DESC
LIMIT 5
```

To get data from the select, all we do is loop through the returned array:

```
foreach ($query as $row) {
    echo "$row['title']\n";
}
```

Using the Smart Join Builder
----------------------------

[](#using-the-smart-join-builder)

Let's start with a traditional join, below:

```
$query = $fluent->from('article')
             ->leftJoin('user ON user.id = article.user_id')
             ->select('user.name');
```

That's pretty verbose, and not very smart. If your tables use proper primary and foreign key names, you can shorten the above to:

```
$query = $fluent->from('article')
             ->leftJoin('user')
             ->select('user.name');
```

That's better, but not ideal. However, it would be even easier to **not write any joins**:

```
$query = $fluent->from('article')
             ->select('user.name');
```

Awesome, right? FluentPDO is able to build the join for you, by you prepending the foreign table name to the requested column.

All three snippets above will create the exact same query:

```
SELECT article.*, user.name
FROM article
LEFT JOIN user ON user.id = article.user_id
```

##### Close your connection

[](#close-your-connection)

Finally, it's always a good idea to free resources as soon as they are done with their duties:

```
$fluent->close();
```

CRUD Query Examples
-------------------

[](#crud-query-examples)

##### SELECT

[](#select)

```
$query = $fluent->from('article')->where('id', 1)->fetch();
$query = $fluent->from('user', 1)->fetch(); // shorter version if selecting one row by primary key
```

##### INSERT

[](#insert)

```
$values = array('title' => 'article 1', 'content' => 'content 1');

$query = $fluent->insertInto('article')->values($values)->execute();
$query = $fluent->insertInto('article', $values)->execute(); // shorter version
```

##### UPDATE

[](#update)

```
$set = array('published_at' => new FluentLiteral('NOW()'));

$query = $fluent->update('article')->set($set)->where('id', 1)->execute();
$query = $fluent->update('article', $set, 1)->execute(); // shorter version if updating one row by primary key
```

##### DELETE

[](#delete)

```
$query = $fluent->deleteFrom('article')->where('id', 1)->execute();
$query = $fluent->deleteFrom('article', 1)->execute(); // shorter version if deleting one row by primary key
```

***Note**: INSERT, UPDATE and DELETE queries will only run after you call `->execute()`*

ToDo
----

[](#todo)

License
-------

[](#license)

Free for commercial and non-commercial use under the [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) or [GPL 2.0](http://www.gnu.org/licenses/gpl-2.0.html) licenses.

###  Health Score

31

—

LowBetter than 71% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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 ~240 days

Total

5

Last Release

555d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.3

1.99.0PHP &gt;7.4 | 8.\*

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d4a5bbb45fc701f595e17c74b94658126704ebc4eafb3fb1aa8bc613cdcbbbd?d=identicon)[KarelWintersky](/maintainers/KarelWintersky)

---

Top Contributors

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

---

Tags

databasemysqldbalpdoquerybuilderfluentdb

###  Code Quality

TestsPHPUnit

Static AnalysisRector

### Embed Badge

![Health badge](/badges/ajur-media-fluentpdo/health.svg)

```
[![Health](https://phpackages.com/badges/ajur-media-fluentpdo/health.svg)](https://phpackages.com/packages/ajur-media-fluentpdo)
```

###  Alternatives

[envms/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

921503.3k13](/packages/envms-fluentpdo)[lichtner/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

921272.0k6](/packages/lichtner-fluentpdo)[fpdo/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

921242.9k7](/packages/fpdo-fluentpdo)[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4572.9M31](/packages/aura-sqlquery)[atlas/query

Object-oriented query builders and performers for MySQL, Postgres, SQLite, and SQLServer.

41246.8k5](/packages/atlas-query)[codesvault/howdy-qb

Mysql Query Builder for WordPress

351.2k1](/packages/codesvault-howdy-qb)

PHPackages © 2026

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