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

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

dino21/fluentpdo
================

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

v3.3(5y ago)095Apache-2.0PHP

Since Feb 24Pushed 5y agoCompare

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

READMEChangelog (1)Dependencies (2)Versions (31)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

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

[](#requirements)

The latest (2.x) release of FluentPDO officially supports PHP 7.2 to PHP 7.4. v2.x is actively maintained.

The legacy (1.x) release of FluentPDO works with PHP 5.4 to 7.1. **Note:** v1.x is no longer supported and will not be maintained or updated.

Reference
---------

[](#reference)

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

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

[](#installation)

### Composer

[](#composer)

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

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

```
"require": {
	...
	"envms/fluentpdo": "^2.2.0"
}

```

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

### Download Zip

[](#download-zip)

If you prefer not to use composer, download the latest release, create the directory `Envms/FluentPDO` in your library directory, and drop this repository into it. Finally, add:

```
require "[lib-dir]/Envms/FluentPDO/src/Query.php";
```

to the top of your application. **Note:** You will need an autoloader to use FluentPDO without changing its source code.

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.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);
$query = $fluent->from('user', 1); // 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()`*

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

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

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 72.2% 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 ~78 days

Recently: every ~0 days

Total

28

Last Release

1969d ago

Major Versions

v1.1.2 → v2.0.0-alpha12017-11-22

v1.1.3 → v2.0.0-alpha22018-08-26

v2.1.2 → v3.x-dev2020-09-30

v2.2.0 → v3.02020-12-14

### Community

Maintainers

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

---

Top Contributors

[![cbornhoft](https://avatars.githubusercontent.com/u/10536543?v=4)](https://github.com/cbornhoft "cbornhoft (200 commits)")[![maldoinc](https://avatars.githubusercontent.com/u/1253062?v=4)](https://github.com/maldoinc "maldoinc (17 commits)")[![sanabria91](https://avatars.githubusercontent.com/u/24279172?v=4)](https://github.com/sanabria91 "sanabria91 (17 commits)")[![diamond-dino21](https://avatars.githubusercontent.com/u/66467436?v=4)](https://github.com/diamond-dino21 "diamond-dino21 (9 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/dino21-fluentpdo/health.svg)

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