PHPackages                             truecastdesign/hopper - 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. [Framework](/categories/framework)
4. /
5. truecastdesign/hopper

ActiveLibrary[Framework](/categories/framework)

truecastdesign/hopper
=====================

This library provides a simple and powerful way to SET and GET records from a PDO database.

v1.9.0(6mo ago)1168↓100%MITPHPPHP &gt;=5.5.0

Since Dec 6Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/truecastdesign/hopper)[ Packagist](https://packagist.org/packages/truecastdesign/hopper)[ RSS](/packages/truecastdesign-hopper/feed)WikiDiscussions master Synced today

READMEChangelog (10)DependenciesVersions (28)Used By (0)

Hopper - Database Abstraction Layer (DBAL) for PHP
==================================================

[](#hopper---database-abstraction-layer-dbal-for-php)

This library provides a simple and powerful way to SET and GET records from a PDO database. It has many powerful database interaction methods that have been developed over the past 10 years.

Install
-------

[](#install)

To install with composer:

```
composer require truecastdesign/hopper
```

Requires PHP 5.5 or newer.

Usage
-----

[](#usage)

Here's a basic usage example:

```
# composer autoloader
require '/path/to/vendor/autoload.php';

# create a new instance of the Hopper class
$DB = new \Truecast\Hopper(['type'=>'mysql', 'username'=>'', 'password'=>'', 'database'=>'']);

# insert a record
$DB->set('table_name', ['first_name'=>'John', 'last_name'=>'Doe', 'phone'=>'541-555-5555', 'status'=>'live']);  # id:1
$DB->set('table_name', ['first_name'=>'Tim', 'last_name'=>'Baldwin', 'phone'=>'541-555-5551', 'status'=>'live']); # id:2

# update a record
$DB->set('table_name', ['id'=>1, 'phone'=>'541-555-5556']);

# execute your own update or insert query and check if it was successful
if ($DB->execute('update tablename set field1=?, field2=? where field3=?', ['val1', 'val2', 'val3'])) {
	# updated row
} else {
	# didn't update row
}

# execute your own update or insert query and check if it was successful
if ($DB->execute('insert into tablename set field1=?, field2=? where field3=?', ['val1', 'val2', 'val3'])) {
	# updated row
} else {
	# didn't update row
}

# get single record
$recordObj = $DB->get('select * from table_name where id=?', [1], 'object');
$recordArray = $DB->get('select * from table_name where id=?', [1], 'array');

# output:
stdClass Object ('id'=>1, first_name'=>'John', 'last_name'=>'Doe', 'phone'=>'541-555-5555', 'status'=>'live')
Array ('id'=>1, first_name'=>'John', 'last_name'=>'Doe', 'phone'=>'541-555-5555', 'status'=>'live')

# get a single value
$value = $DB->get('select first_name from table_name where id=?', [1], 'value');

# output
string 'John'

# get several records
$recordList = $DB->get('select id,first_name,last_name from table_name where status=?', ["live"], '2dim');

# output
Array (	[0]=>Array ('id'=>1, first_name'=>'John', 'last_name'=>'Doe')
		[1]=>Array ('id'=>2, 'first_name'=>'Tim', 'last_name'=>'Baldwin'))
```

Create config file in the format and the truecastdesign/config class to turn it into an object to pass to the construct. This allows you to store configuration in an ini file.

```
; MySQL database config

config_title = 'mysql'
type = 'mysql'
hostname = 'localhost'
username = 'root'
password  = 'password'
database  = 'dbname'
port = 3306
persistent = true
emulate_prepares = false
compress = true
charset = 'utf8'
buffer = true
sslCertAuthority = '' // The file path to the SSL certificate authority.
sslCaCertificates = '' // The file path to the directory that contains the trusted SSL CA certificates, which are stored in PEM format.
sslCert = '' // The file path to the SSL certificate.
sslCipher = '' // A list of one or more permissible ciphers to use for SSL encryption, in a format understood by OpenSSL. For example: DHE-RSA-AES256-SHA:AES128-SHA
sslKey = '' // The file path to the SSL key.
sslVerifyCert = '' // Provides a way to disable verification of the server SSL certificate.
multiStatements = '' // Disables multi query execution in both PDO::prepare() and PDO::query() when set to false.
```

Instantiate using a config file.

```
$DB = new \Truecast\Hopper($Config->mysql);
```

Delete a record

```
$DB->delete('table_name', 1); # deletes record with id=1

$DB->delete('table_name', 'value', 'field_name'); # deletes records with field_name='value'
```

There is a method for setting a record into a Scalable Key-Value table.

Scalable Key-Value table is a table that have field names like id, record\_id, key, value. Each key-value pair in a records is stored in its own table row. This way you can dynamically add and remove fields you want to store.

```
$settings = ['record_id_field'=>'record_id', 'record_id'=>1, 'key_field'=>'field_name', 'value_field'=>'value'];

$DB->setScalableKeyValue('table_name', ['first_name'=>'John', 'last_name'=>'Doe', 'phone'=>'541-555-5555', 'status'=>'live'], $settings)
```

More method documentation coming as soon as I have time to write it up.

Empty a table of data
=====================

[](#empty-a-table-of-data)

```
$DB->emptyTable('table_name');
```

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance69

Regular maintenance activity

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity68

Established project with proven stability

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

Total

27

Last Release

181d ago

### Community

Maintainers

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

---

Top Contributors

[![truecastdesign](https://avatars.githubusercontent.com/u/18723650?v=4)](https://github.com/truecastdesign "truecastdesign (21 commits)")

---

Tags

phpframeworkabstractiondatabaseslimdbaldblayerdbpdo

### Embed Badge

![Health badge](/badges/truecastdesign-hopper/health.svg)

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

###  Alternatives

[slim/php-view

Render PHP view scripts into a PSR-7 Response object.

2839.6M89](/packages/slim-php-view)[davidepastore/slim-config

A slim middleware to read configuration from different files based on hassankhan/config

358.9k1](/packages/davidepastore-slim-config)[usbac/wolff-framework

Web development made just right

381.2k](/packages/usbac-wolff-framework)[patricksavalle/slim-rest-api

Production-grade REST-API App-class for PHP SLIM, in production on https://zaplog.pro (https://api.zaplog.pro/v1)

101.4k](/packages/patricksavalle-slim-rest-api)

PHPackages © 2026

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