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

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

advmaker/fluentpdo
==================

FluentPDO is small PHP library for rapid query building. Killer feature is smart join builder which generates joins automatically.

1.1.0(10y ago)0264Apache-2.0PHP

Since Feb 24Pushed 10y ago1 watchersCompare

[ Source](https://github.com/advmaker/fluentpdo)[ Packagist](https://packagist.org/packages/advmaker/fluentpdo)[ Docs](http://fluentpdo.com/)[ RSS](/packages/advmaker-fluentpdo/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (4)Used By (0)

FluentPDO [![Build Status](https://camo.githubusercontent.com/6a9632589146f430453de69b30145dac90c573f302b1220284c47c30cdee5360/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f6c696368746e65722f666c75656e7470646f2e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/lichtner/fluentpdo)
============================================================================================================================================================================================================================================================================================================

[](#fluentpdo-)

FluentPDO - smart SQL builder for PHP.

FluentPDO is small PHP library for rapid query building. Killer feature is "Smart join builder" which generates joins automatically.

Features
--------

[](#features)

- Fluent interface for creating queries step by step
- Smart join builder
- Simple API based on PDO and SQL syntax
- Build SELECT, INSERT, UPDATE &amp; DELETE queries
- Small and fast
- Type hinting with code completion in smart IDEs
- Requires PHP 5.1+ with any database supported by PDO

Reference
---------

[](#reference)

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

Install
-------

[](#install)

### Composer

[](#composer)

The preferred way to install FluentPDO is via [composer](http://getcomposer.org/).

Add in your `composer.json`:

```
"require": {
	...
	"lichtner/fluentpdo": "dev-master"
}

```

then update your dependencies with `composer update`.

### Copy

[](#copy)

If you are not familiar with composer just copy `/FluentPDO` directory into your `libs/` directory then:

```
include "libs/FluentPDO/FluentPDO.php";
```

Start usage
-----------

[](#start-usage)

```
$pdo = new PDO("mysql:dbname=fblog", "root");
$fpdo = new FluentPDO($pdo);
```

First example
-------------

[](#first-example)

FluentPDO is easy to use:

```
$query = $fpdo->from('article')
            ->where('published_at > ?', $date)
            ->orderBy('published_at DESC')
            ->limit(5);
foreach ($query as $row) {
    echo "$row[title]\n";
}
```

executed query is:

```
SELECT article.*
FROM article
WHERE published_at > ?
ORDER BY published_at DESC
LIMIT 5
```

Smart join builder (how to build queries)
-----------------------------------------

[](#smart-join-builder-how-to-build-queries)

If you want to join table you can use full sql join syntax. For example we would like to show list of articles with author name:

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

It was not so much smart, was it? ;-) If your database uses convention for primary and foreign key names, you can write only:

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

Smarter? May be. but **best practice how to write joins is not to write any joins ;-)**

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

All three commands create same query:

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

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

[](#simple-crud-query-examples)

##### SELECT

[](#select)

```
$query = $fpdo->from('article')->where('id', 1);
// or shortly if you select one row by primary key
$query = $fpdo->from('user', 1);
```

##### INSERT

[](#insert)

```
$values = array('title' => 'article 1', 'content' => 'content 1');
$query = $fpdo->insertInto('article')->values($values)->execute();
// or shortly
$query = $fpdo->insertInto('article', $values)->execute();
```

##### UPDATE

[](#update)

```
$set = array('published_at' => new FluentLiteral('NOW()'));
$query = $fpdo->update('article')->set($set)->where('id', 1)->execute();
// or shortly if you update one row by primary key
$query = $fpdo->update('article', $set, 1)->execute();
```

##### DELETE

[](#delete)

```
$query = $fpdo->deleteFrom('article')->where('id', 1)->execute();
// or shortly if you delete one row by primary key
$query = $fpdo->deleteFrom('article', 1)->execute();
```

*Note: INSERT, UPDATE and DELETE will be executed after `->execute()`:*

Full documentation can be found on the [FluentPDO homepage](http://lichtner.github.io/fluentpdo/)

Licence
-------

[](#licence)

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

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor4

4 contributors hold 50%+ of commits

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

Total

2

Last Release

3759d ago

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/7be6fefda4aa20b4f84c1248bf89b159665a8c020a61e09a17ec0a5f65af04f9?d=identicon)[Puppollo](/maintainers/Puppollo)

---

Top Contributors

[![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)")[![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)")[![jk3us](https://avatars.githubusercontent.com/u/41621?v=4)](https://github.com/jk3us "jk3us (1 commits)")[![Kaile](https://avatars.githubusercontent.com/u/5454122?v=4)](https://github.com/Kaile "Kaile (1 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)")[![Puppollo](https://avatars.githubusercontent.com/u/7393039?v=4)](https://github.com/Puppollo "Puppollo (1 commits)")[![StefanYohansson](https://avatars.githubusercontent.com/u/1783252?v=4)](https://github.com/StefanYohansson "StefanYohansson (1 commits)")[![Ellrion](https://avatars.githubusercontent.com/u/1150861?v=4)](https://github.com/Ellrion "Ellrion (1 commits)")[![tmihalik](https://avatars.githubusercontent.com/u/440762?v=4)](https://github.com/tmihalik "tmihalik (1 commits)")[![gephaest](https://avatars.githubusercontent.com/u/1038708?v=4)](https://github.com/gephaest "gephaest (1 commits)")

---

Tags

databasedbalpdo

### Embed Badge

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

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

###  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)[dibi/dibi

Dibi is Database Abstraction Library for PHP

5013.8M120](/packages/dibi-dibi)[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)[tommyknocker/pdo-database-class

Framework-agnostic PHP database library with unified API for MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, and Oracle. Query Builder, caching, sharding, window functions, CTEs, JSON, migrations, ActiveRecord, CLI tools, AI-powered analysis. Zero external dependencies.

845.7k](/packages/tommyknocker-pdo-database-class)

PHPackages © 2026

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