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

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

geste/fluentpdo
===============

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

4.1.1(3y ago)11671Apache-2.0PHPPHP &gt;=8

Since May 25Pushed 3y agoCompare

[ Source](https://github.com/steltner/fluentpdo)[ Packagist](https://packagist.org/packages/geste/fluentpdo)[ Docs](https://github.com/steltner/fluentpdo)[ RSS](/packages/geste-fluentpdo/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependencies (1)Versions (9)Used By (1)

FluentPDO
=========

[](#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

Requirements
------------

[](#requirements)

Version 4 release supports PHP 8 and is actively maintained.

Reference
---------

[](#reference)

[Sitepoint - Getting Started with FluentPDO](http://www.sitepoint.com/getting-started-fluentpdo/)(No longer fully compatible)

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

[](#installation)

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

```
"require": {
	...
	"geste/fluentpdo": "^4"
}

```

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', 'root');
$fluent = new \Envms\FluentPDO\Query($pdo);
```

Then, creating queries is quick and easy:

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

which would build the query below:

```
SELECT comment.*
FROM comment
LEFT JOIN article ON article.articleId = comment.articleId
WHERE article.publishedAt > ?
ORDER BY article.publishedAt 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'] . PHP_EOL;
}
```

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.userId = article.userId')
             ->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.userId = article.userId
```

##### 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);
$query = $fluent->from('user', 1); // shorter version if selecting one row by primary key
```

##### INSERT

[](#insert)

```
$values = ['title' => 'article 1', 'content' => 'content 1'];

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

##### UPDATE

[](#update)

```
$set = ['published_at' => new Literal('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()`*

Full documentation can be found on the [FluentPDO homepage](http://envms.github.io/fluentpdo/) but is partly no longer compatible anymore!

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

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 67.1% 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 ~112 days

Total

8

Last Release

1395d ago

Major Versions

3.1.1 → 4.0.02021-04-19

PHP version history (2 changes)3.0.0PHP ^7.4

3.1.1PHP &gt;=8

### Community

Maintainers

![](https://www.gravatar.com/avatar/eb87d57783fdfc29315f11d5cc2d38671f6f0a922d51e8efa463a8b6f34904f7?d=identicon)[geste](/maintainers/geste)

---

Top Contributors

[![cbornhoft](https://avatars.githubusercontent.com/u/10536543?v=4)](https://github.com/cbornhoft "cbornhoft (200 commits)")[![steltner](https://avatars.githubusercontent.com/u/5311684?v=4)](https://github.com/steltner "steltner (30 commits)")[![sanabria91](https://avatars.githubusercontent.com/u/24279172?v=4)](https://github.com/sanabria91 "sanabria91 (17 commits)")[![maldoinc](https://avatars.githubusercontent.com/u/1253062?v=4)](https://github.com/maldoinc "maldoinc (17 commits)")[![StefanYohansson](https://avatars.githubusercontent.com/u/1783252?v=4)](https://github.com/StefanYohansson "StefanYohansson (7 commits)")[![jkufner](https://avatars.githubusercontent.com/u/16572?v=4)](https://github.com/jkufner "jkufner (6 commits)")[![cj-clx](https://avatars.githubusercontent.com/u/46033285?v=4)](https://github.com/cj-clx "cj-clx (4 commits)")[![maratK13](https://avatars.githubusercontent.com/u/3388197?v=4)](https://github.com/maratK13 "maratK13 (2 commits)")[![dczech](https://avatars.githubusercontent.com/u/2190435?v=4)](https://github.com/dczech "dczech (2 commits)")[![mta59066](https://avatars.githubusercontent.com/u/936941?v=4)](https://github.com/mta59066 "mta59066 (1 commits)")[![pkoutsias](https://avatars.githubusercontent.com/u/5034122?v=4)](https://github.com/pkoutsias "pkoutsias (1 commits)")[![tmihalik](https://avatars.githubusercontent.com/u/440762?v=4)](https://github.com/tmihalik "tmihalik (1 commits)")[![Alpine418](https://avatars.githubusercontent.com/u/4191615?v=4)](https://github.com/Alpine418 "Alpine418 (1 commits)")[![yurirnascimento](https://avatars.githubusercontent.com/u/4502631?v=4)](https://github.com/yurirnascimento "yurirnascimento (1 commits)")[![BenLorantfy](https://avatars.githubusercontent.com/u/4398635?v=4)](https://github.com/BenLorantfy "BenLorantfy (1 commits)")[![dima-stefantsov](https://avatars.githubusercontent.com/u/1370909?v=4)](https://github.com/dima-stefantsov "dima-stefantsov (1 commits)")[![gsouf](https://avatars.githubusercontent.com/u/3215399?v=4)](https://github.com/gsouf "gsouf (1 commits)")[![jay-knight](https://avatars.githubusercontent.com/u/42975397?v=4)](https://github.com/jay-knight "jay-knight (1 commits)")[![Jazz-Man](https://avatars.githubusercontent.com/u/6892898?v=4)](https://github.com/Jazz-Man "Jazz-Man (1 commits)")[![jk3us](https://avatars.githubusercontent.com/u/41621?v=4)](https://github.com/jk3us "jk3us (1 commits)")

---

Tags

databasemysqldbalpdooraclequerybuilderfluentdb

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/geste-fluentpdo/health.svg)](https://phpackages.com/packages/geste-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.

925511.7k13](/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.

921274.8k6](/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.

921244.9k7](/packages/fpdo-fluentpdo)[doctrine/dbal

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

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

Dibi is Database Abstraction Library for PHP

5013.8M120](/packages/dibi-dibi)[aura/sqlquery

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

4572.9M34](/packages/aura-sqlquery)

PHPackages © 2026

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