PHPackages                             evolutionphp/database - 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. evolutionphp/database

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

evolutionphp/database
=====================

Codeigniter 3 standalone database (MySQL).

1.2(2y ago)026MITPHPPHP &gt;=8.2

Since Mar 7Pushed 2y ago1 watchersCompare

[ Source](https://github.com/EvolutionPHP/database)[ Packagist](https://packagist.org/packages/evolutionphp/database)[ RSS](/packages/evolutionphp-database/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

Simple Database Library
=======================

[](#simple-database-library)

Codeigniter 3 standalone database (MySQL).

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

[](#installation)

Use [Composer](http://getcomposer.org) to install Logger into your project:

```
composer require evolutionphp/database
```

Configuration
-------------

[](#configuration)

1. Set configuration var with details of database

```
$data = array(
	'hostname' => 'localhost', //Database Hostname
	'username' => 'root', //Database Username
	'password' => 'root', //Database Password
	'database' => 'mydb', //Database Name
	'table_prefix' => '', //Table prefix
	'char_set' => 'utf8mb4', //Database chart set
	'dbcollat' => 'utf8mb4_bin', //Database collation
	'port' => '', //Enter if you know the port number, otherwise leave empty
);
```

2. Initialize class

```
$db = \EvolutionPHP\Database\Database::connect($data);
```

Call instance
-------------

[](#call-instance)

If you already initialize the Database class, then you can call an instance

```
$db = \EvolutionPHP\Database\Database::connect();
```

Usage Examples
--------------

[](#usage-examples)

**Standard Query With Multiple Results (Object Version)**

This is optional, you can save logs of errors. For params of logger go to [SimpleLogger](https://github.com/EvolutionPHP/logger)

```
$query = $db->query('SELECT name, title, email FROM my_table');

foreach ($query->result() as $row)
{
        echo $row->title;
        echo $row->name;
        echo $row->email;
}

echo 'Total Results: ' . $query->num_rows();
```

**Standard Query With Single Result**

```
$query = $this->db->query('SELECT name FROM my_table LIMIT 1');
$row = $query->row();
echo $row->name;
```

**Standard Insert**

```
$sql = "INSERT INTO mytable (title, name) VALUES (".$this->db->escape($title).", ".$this->db->escape($name).")";
$this->db->query($sql);
echo $this->db->affected_rows();
```

**Query Builder Insert**

```
$data = array(
        'title' => $title,
        'name' => $name,
        'date' => $date
);

$this->db->insert('mytable', $data);  // Produces: INSERT INTO mytable (title, name, date) VALUES ('{$title}', '{$name}', '{$date}')
```

For more information visit [CodeIgniter3 Query Builder](http://www.codeigniter.com/userguide3/database/query_builder.html)

Database Manipulation
---------------------

[](#database-manipulation)

The Database Forge Class contains methods that help you manage your database.

**Initializing the Forge Class**

```
$forge = new \EvolutionPHP\Database\Library\Forge($db);
```

**Creating a table**Fields are created via an associative array. Within the array you must include a ‘type’ key that relates to the datatype of the field. For example, INT, VARCHAR, TEXT, etc. Many datatypes (for example VARCHAR) also require a ‘constraint’ key.

```
$fields = array(
        'blog_id' => array(
                'type' => 'INT',
                'constraint' => 5,
                'unsigned' => TRUE,
                'auto_increment' => TRUE
        ),
        'blog_title' => array(
                'type' => 'VARCHAR',
                'constraint' => '100',
                'unique' => TRUE,
        ),
        'blog_author' => array(
                'type' =>'VARCHAR',
                'constraint' => '100',
                'default' => 'King of Town',
        ),
        'blog_description' => array(
                'type' => 'TEXT',
                'null' => TRUE,
        ),
);
$forge->add_field($fields);
```

Lets add keys

```
$forge->add_key('blog_id', TRUE);
// gives PRIMARY KEY `blog_id` (`blog_id`)

$forge->add_key('blog_name');
// gives KEY `blog_name` (`blog_name`)
```

Creating a table

```
$forge->create_table('table_name', TRUE);
// gives CREATE TABLE IF NOT EXISTS table_name
```

For more information visit [CodeIgniter3 Database Forge Class](https://codeigniter.com/userguide3/database/forge.html)

Authors
-------

[](#authors)

This library was primarily developed by [CodeIgniter 3](http://www.codeigniter.com/userguide3/database/index.html) and modified by [Andres M](https://twitter.com/EvolutionPHP) for standalone use.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 87.5% 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 ~159 days

Total

3

Last Release

885d ago

PHP version history (2 changes)1.0PHP &gt;=7.4

1.2PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d5a42f2155ba37cd77c46f9e57c613e0c08394b5e2b59e8ff77e0d44adaf907?d=identicon)[EvolutionPHP](/maintainers/EvolutionPHP)

---

Top Contributors

[![EvolutionPHP](https://avatars.githubusercontent.com/u/106336615?v=4)](https://github.com/EvolutionPHP "EvolutionPHP (7 commits)")[![aqpdev](https://avatars.githubusercontent.com/u/143758553?v=4)](https://github.com/aqpdev "aqpdev (1 commits)")

---

Tags

databasemysqlcodeigniter

### Embed Badge

![Health badge](/badges/evolutionphp-database/health.svg)

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

###  Alternatives

[rah/danpu

Zero-dependency MySQL dump library for easily exporting and importing databases

62410.3k11](/packages/rah-danpu)

PHPackages © 2026

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