PHPackages                             shen2/fluent-cql - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. shen2/fluent-cql

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

shen2/fluent-cql
================

an php CQL building library

78.5k5[1 PRs](https://github.com/shen2/FluentCQL/pulls)PHP

Since Jul 19Pushed 10y ago5 watchersCompare

[ Source](https://github.com/shen2/FluentCQL)[ Packagist](https://packagist.org/packages/shen2/fluent-cql)[ RSS](/packages/shen2-fluent-cql/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

FluentCQL
=========

[](#fluentcql)

Dependency
----------

[](#dependency)

- PHP 5.4+
- [duoshuo/php-cassandra](https://github.com/duoshuo/php-cassandra) (Required)
- [duoshuo/uuid](https://github.com/duoshuo/uuid) (Optional)

Initialize
----------

[](#initialize)

```
$connection = new Cassandra\Connection(['127.0.0.1'], 'my_keyspace');
```

FluentCQL\\Query
----------------

[](#fluentcqlquery)

- SELECT COMMAND

```
$query = FluentCQL\Query::select('count(*)')
    ->from('table_name')
    ->where('id = ?', 123);

$query->assemble(); // SELECT count(*) FROM table_name where id = 123
$query->setDbAdapter($connection)->querySync(); // execute query syncronously
```

- INSERT COMMAND

```
$query = FluentCQL\Query::insertInto('table_name')
    ->clause('(from_id, to_id, updated_uuid)')
    ->values('(?, ?, ?)', 321, 123, new \Cassandra\Type\Timeuuid('2dc65ebe-300b-11e4-a23b-ab416c39d509'));

$query->assemble(); // INSERT INTO table_name (from_id, to_id, updated_uuid) values (321, 123, 2dc65ebe-300b-11e4-a23b-ab416c39d509);
$query->setDbAdapter($connection)->querySync(); // execute query syncronously
```

- UPDATE COMMAND

```
$query = FluentCQL\Query::update('table_name')
    ->set('a = :a, b = :b', $a, $b)
    ->where('c = :c', $c)
    ->and('d = :d', $d)
    ->ifExists();

$query->assemble(); // 'UPDATE table_name SET a = :a, b = :b WHERE c = :c AND d = :d'
$query->setDbAdapter($connection)->querySync(); // execute query syncronously
```

- DELETE COMMAND

```
$query = FluentCQL\Query::delete()
    ->from('table_name')
    ->where('id = ?', 123);

$query->assemble(); // DELETE FROM table_name where id = 123
$query->setDbAdapter($connection)->querySync(); // execute query syncronously
```

FluentCQL\\Table
----------------

[](#fluentcqltable)

### Table Class Definition

[](#table-class-definition)

```
class Friendship extends \FluentCQL\Table{

    protected static $_name = 'friendship';

    protected static $_primary = array('from_id', 'to_id');

    protected static $_columns = array(
            'from_id'      => Type\Base::BIGINT,
            'to_id'        => Type\Base::BIGINT,
            'updated_uuid' => Type\Base::TIMEUUID,
    );

    protected static $_readConsistency = 0x0001;

    protected static $_writeConsistency = 0x0002;
}
```

### Initialize

[](#initialize-1)

```
$connection = new Cassandra\Connection(['127.0.0.1'], 'my_keyspace');
FluentCQL\Table::setDefaultDbAdapter($connection);
```

### Queries

[](#queries)

- Table::find()

```
$response = Friendship::find(321, 123);     // synchronously query and get binary response
$response->fetchAll(); // get all rows in a SplFixedArray
$response->fetchRow(); // get first row in a ArrayObject from response
```

- Table::select()

```
// this way totally equal to Friendship::find()
$response = Friendship::select()
    ->where('from_id = ? AND to_id = ?', 321, 123)
    ->querySync();
```

- Table::insert()

```
$response = Friendship::insert()
    ->clause('(from_id, to_id, updated_uuid)')
    ->values('(?, ?, ?)', 321, 123, new \Cassandra\Type\Timeuuid('2dc65ebe-300b-11e4-a23b-ab416c39d509'))
    ->querySync();
```

- Table::update()

```
$response = Friendship::update()
    ->set('update_uuid = ?', new \Cassandra\Type\Timeuuid('2dc65ebe-300b-11e4-a23b-ab416c39d509'))
    ->where('from_id = ? AND to_id = ?', 321, 123)
    ->querySync();
```

- Table::delete()

```
$response = Friendship::delete()
    ->where('from_id = ? AND to_id = ?', 321, 123)
    ->if('updated_uuid = ?', new \Cassandra\Type\Timeuuid('2dc65ebe-300b-11e4-a23b-ab416c39d509'))
    ->querySync();
```

- Table::insertRow($data)

```
// Insert a row through an array.
$response = Friendship::insertRow([
    'from_id' => 123,
    'to_id'   => 321,
    'updated_uuid'=> '2dc65ebe-300b-11e4-a23b-ab416c39d509',
])->querySync();
```

- Table::updateRow($primary, $data)

```
// Update a row by primary key.
$response = Friendship::updateRow([123, 321], ['updated_uuid'=> '2dc65ebe-300b-11e4-a23b-ab416c39d509'])->querySync();
```

- Table::deleteRow($primary)

```
// Delete a row or rows by primary key.
$response = Friendship::deleteRow([123])->querySync();
```

### Custom Consistency and Options

[](#custom-consistency-and-options)

```
$query = new FluentCQL\Query();
$query->setConsistency(0x0001)
    ->setOptions(['page_size' => 20]);
```

### ActiveRecord-like Usage

[](#activerecord-like-usage)

```
$post = new Friendship();
$post['from_id']      = 123;
$post['to_id']        = 321;
$post['updated_uuid'] = '2dc65ebe-300b-11e4-a23b-ab416c39d509';
$post->save();
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.4% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2515a1b7a6e85454fd15245886d030202007d1329757aa4bf0d0123f49789279?d=identicon)[shen2](/maintainers/shen2)

---

Top Contributors

[![shen2](https://avatars.githubusercontent.com/u/1523457?v=4)](https://github.com/shen2 "shen2 (26 commits)")[![maliemin-Mstar](https://avatars.githubusercontent.com/u/3032500?v=4)](https://github.com/maliemin-Mstar "maliemin-Mstar (11 commits)")[![cuebito](https://avatars.githubusercontent.com/u/7549602?v=4)](https://github.com/cuebito "cuebito (1 commits)")

### Embed Badge

![Health badge](/badges/shen2-fluent-cql/health.svg)

```
[![Health](https://phpackages.com/badges/shen2-fluent-cql/health.svg)](https://phpackages.com/packages/shen2-fluent-cql)
```

PHPackages © 2026

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