PHPackages                             kinoritech/fast-mysql - 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. kinoritech/fast-mysql

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

kinoritech/fast-mysql
=====================

lightweight database class

1.0.0(3y ago)06MITPHP

Since Jun 23Pushed 3y ago1 watchersCompare

[ Source](https://github.com/KinoriTech/FastMysql)[ Packagist](https://packagist.org/packages/kinoritech/fast-mysql)[ Docs](https://github.com/KinoriTech/FastMysql)[ RSS](/packages/kinoritech-fast-mysql/feed)WikiDiscussions main Synced 4w ago

READMEChangelogDependenciesVersions (2)Used By (0)

FastMysql
=========

[](#fastmysql)

This lightweight database class is written with PHP and uses the MySQLi extension, it uses prepared statements to properly secure your queries, no need to worry about SQL injection attacks.

Based on the code at by David Adams at [super-fast-php-mysql-database-class](https://codeshack.io/super-fast-php-mysql-database-class/).

The MySQLi extension has built-in prepared statements that you can work with, this will prevent SQL injection and prevent your database from being exposed, some developers are confused on how to use these methods correctly so David created (and we refined) this easy to use database class that'll do the work for you.

This database class is beginner-friendly and easy to implement, with the native MySQLi methods you need to write 3-7 lines of code to retrieve data from a database, with this class you can do it with just 1-2 lines of code, and is much easier to understand.

Install
-------

[](#install)

The recommended way is via composer:

```
composer require kinoritech/fast-mysql
```

How To Use
----------

[](#how-to-use)

### Connect to MySQL database:

[](#connect-to-mysql-database)

```
use KinoriTech\FastMysql\Connection;

$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = 'example';

$db = new Connection($dbhost, $dbuser, $dbpass, $dbname);
```

### Fetch a record from a database:

[](#fetch-a-record-from-a-database)

```
$account = $db->query('SELECT * FROM accounts WHERE username = ? AND password = ?', 'test', 'test')->fetchArray();
echo $account['name'];
```

Or you could do:

```
$account = $db->query('SELECT * FROM accounts WHERE username = ? AND password = ?', array('test', 'test'))->fetchArray();
echo $account['name'];
```

### Fetch multiple records from a database:

[](#fetch-multiple-records-from-a-database)

```
$accounts = $db->query('SELECT * FROM accounts')->fetchAll();

foreach ($accounts as $account) {
    echo $account['name'] . '';
}
```

You can specify a callback if you do not want the results being stored in an array (useful for large amounts of data):

```
$db->query('SELECT * FROM accounts')->fetchAll(function($account) {
echo $account['name'];
});
```

If you need to break the loop you can add:

`return 'break';`

### Get the number of rows:

[](#get-the-number-of-rows)

```
$accounts = $db->query('SELECT * FROM accounts');
echo $accounts->numRows();
```

### Get the affected number of rows:

[](#get-the-affected-number-of-rows)

```
$insert = $db->query('INSERT INTO accounts (username,password,email,name) VALUES (?,?,?,?)', 'test', 'test', 'test@gmail.com', 'Test');
echo $insert->affectedRows();
```

### Get the total number of queries:

[](#get-the-total-number-of-queries)

```
echo $db->query_count;
```

### Get the last insert ID:

[](#get-the-last-insert-id)

```
echo $db->lastInsertID();
```

### Close the database:

[](#close-the-database)

```
$db->close();
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

Unknown

Total

1

Last Release

1415d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c7fb707167b15d214e668184364f7683162cf86684bab1991913a4c4131cb6be?d=identicon)[h.hoyos](/maintainers/h.hoyos)

---

Top Contributors

[![arcanefoam](https://avatars.githubusercontent.com/u/2157165?v=4)](https://github.com/arcanefoam "arcanefoam (5 commits)")

---

Tags

database

### Embed Badge

![Health badge](/badges/kinoritech-fast-mysql/health.svg)

```
[![Health](https://phpackages.com/badges/kinoritech-fast-mysql/health.svg)](https://phpackages.com/packages/kinoritech-fast-mysql)
```

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

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[doctrine/doctrine-bundle

Symfony DoctrineBundle

4.8k241.3M3.3k](/packages/doctrine-doctrine-bundle)[doctrine/migrations

PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and easily deploying changes to it. It is a very easy to use and a powerful tool.

4.8k204.8M438](/packages/doctrine-migrations)[doctrine/data-fixtures

Data Fixtures for all Doctrine Object Managers

2.9k136.1M516](/packages/doctrine-data-fixtures)[robmorgan/phinx

Phinx makes it ridiculously easy to manage the database migrations for your PHP app.

4.5k46.2M401](/packages/robmorgan-phinx)

PHPackages © 2026

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