PHPackages                             uk/db - 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. uk/db

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

uk/db
=====

The UniKado database DB library.

0.1.2(9y ago)014LGPLv3PHPPHP &gt;=7.0

Since Jul 3Pushed 9y ago1 watchersCompare

[ Source](https://github.com/UniKado/UK.DB)[ Packagist](https://packagist.org/packages/uk/db)[ RSS](/packages/uk-db/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

UK.DB
=====

[](#ukdb)

The UniKado database DB library

Usage
-----

[](#usage)

```
use UK\DB\Connection;

try
{

   // Open the PGSQL connection (for example)
   $conn = Connection::CreatePgSQL(
      '127.0.0.1',
      'my_database',
      'db_user',
      'db_password',
      'UTF8',
      5432
   );

   // Fetch all records with an foo value > 0
   $records = $conn->fetchAll(
      'SELECT foo, bar, baz from my_table WHERE foo > ?',
      [ 0 ]
   );

   // Output the returned records
   print_r( $records );

}
catch ( \Exception $ex )
{

   echo $ex;
   exit;

}
```

Version history
---------------

[](#version-history)

### 0.1.2

[](#012)

#### Fixing [first issue #1](https://github.com/UniKado/UK.DB/issues/1)

[](#fixing-first-issue-1)

This adds 2 new methods to [\\UK\\DB\\Connection](https://github.com/UniKado/UK.DB/blob/master/src/UK/DB/Connection.php)

- [\\UK\\DB\\Connection::getParseQueryVarsAlways() : bool](https://github.com/UniKado/UK.DB/blob/master/src/UK/DB/Connection.php#LC546)
- [\\UK\\DB\\Connection::setParseQueryVarsAlways( bool $value )](https://github.com/UniKado/UK.DB/blob/master/src/UK/DB/Connection.php#LC562)

The methods let you set or get a flag that declares if the parsing of used SQL query string for defined Query-Vars should be executed always. Otherwise it will only be parsed if there are some Query-Vars defined.

### 0.1.1

[](#011)

#### Introducing Query-Vars. (Pre prepared statements)

[](#introducing-query-vars-pre-prepared-statements)

**Query-Vars** are key-value pairs, used to replace some placeholders inside an SQL query string with the associated string values.

Its like the regular known prepared statements but usable for query parts where prepared statements will not work. e.g. for an dynamic table name part or something else…

##### Placeholder format restrictions

[](#placeholder-format-restrictions)

Placeholders inside the SQL query string must:

- start with an open curly bracket, followed by the Dollar symbol `{$` and end with the closing curly bracket `}`
- be defined by the 2 parts placeholder-name and default value, separated by the equal sign `=`

The default value is already used if no Query-Var is defined by PHP code.

If no default value should be used the equal sign is mandatory but it throws an exception if no replacement value is declared!

```
{$PlaceholderName=DefaultValue}

```

or 2 variants without an default value

```
{$PlaceholderName=}

{$PlaceholderName}

```

##### Value format restrictions

[](#value-format-restrictions)

- An Query-Vars value must be an string (not null or something else)
- It should not contain two following dashes `--`
- Accepted chars are: `A-Za-z0-9 \t?_:.-`

For example:

If you want to use the following SQL

```
SELECT
      foo,
      bar
   FROM
      my_table
   WHERE
      foo > ?
   ORDER BY
      foo ASC
```

but the order direction part should be dynamic, you can use

```
SELECT
      foo,
      bar
   FROM
      my_table
   WHERE
      foo > ?
   ORDER BY
      foo {$ORDER_DIRECTION=ASC}
```

Example to call this SQL command

```
$records = $connectionInstance->fetchAll(
   // The SQL query string
   'SELECT foo, bar FROM my_table WHERE foo > ? ORDER BY foo {$ORDER_DIRECTION=ASC}',
   // Prepared statement parameters
   [ 0 ],
   \PDO::FETCH_ASSOC
   // The query vars
   [ 'ORDER_DIRECTION' => 'DESC' ]
);
```

### v0.1

[](#v01)

This is the initial first commit.

###  Health Score

23

—

LowBetter than 30% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

Total

3

Last Release

3548d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/89b9d7c9dcc70d30f432d252244a7727383b73059ddc2cc13210b4cd0cfa2800?d=identicon)[UK](/maintainers/UK)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/uk-db/health.svg)

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k280.5M5.5k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k114.4M86](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k51.5M8.1k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k62.7M487](/packages/mongodb-mongodb)[spatie/laravel-translatable

A trait to make an Eloquent model hold translations

2.4k22.1M345](/packages/spatie-laravel-translatable)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.5k23.2M24](/packages/kirschbaum-development-eloquent-power-joins)

PHPackages © 2026

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