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

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

optiwariindia/database
======================

A library to connect database and use basic activities in database like create,select,insert,update,delete and drop using predefined methods

1.2.1(5y ago)12902MITPHP

Since Apr 5Pushed 4y ago1 watchersCompare

[ Source](https://github.com/optiwariindia/database)[ Packagist](https://packagist.org/packages/optiwariindia/database)[ RSS](/packages/optiwariindia-database/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)DependenciesVersions (5)Used By (2)

database : A library to make database interactions easier
=========================================================

[](#database--a-library-to-make-database-interactions-easier)

Supported Databases:
--------------------

[](#supported-databases)

1. MariaDB
2. MySQL

Getting Started
---------------

[](#getting-started)

### Installation

[](#installation)

`composer require optiwariindia/database`

### Geting Started

[](#geting-started)

*Prerequsites:*

- Database Hostname, generally localhost if database is installed on webserver.
- Database Username, usually root for local installations
- Database Password, usually blank for local installations
- Database Name, Generally same as hosting account name

create object of database class `use optiwariindia\database`

`$db=new database([ "host"=>"localhost", "user"=>"root", //Your Database user "pass"=>"", // Your database password "name"=>"{Database Name}" //Your Database Name ])`

### Basic Operations

[](#basic-operations)

#### Insert

[](#insert)

Create an array of the data you want to store in database, set keys as name of fields for example Table auth, contains username and password only, then it shall be written like : `$data=[``"user"=>{Username},``"pass"=>{Password}``];`

And then it can be inserted into auth table like:

`$db->insert("auth",$data);`

#### Select

[](#select)

The database class is providing 4 modes for selecting data as follows:

- mode 0 returns array with following keys:
    - fields: Array showing list of fields
    - rows: number of rows
    - touples with numeric indicies i.e. $data\[0\] shows first row.
- mode 1 returns rows as array containing filed names as key for each row.
- mode 2 returns id as row index and each row as collection of fields where field names are keys
- mode 3 returns same as mode 1 but parses all json arrays and eliminates all blobs. By default mode 0 is selected in the object. To change mode you can use following: `$db->mode({mode number})`To select Data from any table you can use following: ` $data= $db->select({table name},{filelds (optional, * by default)},{clauses})`

#### Update

[](#update)

The update function can be used to update data in a table. to update data create an array with filedname as keys like: `$data=[``"{field to be updated}"=>"{filed value}"``];`and then `$db->update({table name},$data,{clause if any (Optional)});`

#### Delete

[](#delete)

`$db->delete({tablename},{clause if any (optional)});`

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 57.1% 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 ~249 days

Total

4

Last Release

1849d ago

### Community

Maintainers

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

---

Top Contributors

[![optiwariindia](https://avatars.githubusercontent.com/u/4514495?v=4)](https://github.com/optiwariindia "optiwariindia (4 commits)")[![optiwariivaid](https://avatars.githubusercontent.com/u/44803639?v=4)](https://github.com/optiwariivaid "optiwariivaid (3 commits)")

### Embed Badge

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

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

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

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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