PHPackages                             aleksey.nemiro/nemiro.data.php - 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. aleksey.nemiro/nemiro.data.php

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

aleksey.nemiro/nemiro.data.php
==============================

The small helper classes for working with databases MySql and PostgreSQL.

2.0(10y ago)121Apache License 2.0PHPPHP &gt;=5.3.0

Since Nov 2Pushed 10y ago1 watchersCompare

[ Source](https://github.com/phperry/Nemiro.Data.PHP)[ Packagist](https://packagist.org/packages/aleksey.nemiro/nemiro.data.php)[ Docs](https://github.com/alekseynemiro/Nemiro.Data.PHP)[ RSS](/packages/alekseynemiro-nemirodataphp/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

### Nemiro.Data.PHP [![Latest Stable Version](https://camo.githubusercontent.com/b105f1acea3de447a57f3046ca76ebd8121b36094d1228a1e8c2517bc385a1be/68747470733a2f2f706f7365722e707567782e6f72672f616c656b7365792e6e656d69726f2f6e656d69726f2e646174612e7068702f762f737461626c65)](https://packagist.org/packages/aleksey.nemiro/nemiro.data.php) [![Total Downloads](https://camo.githubusercontent.com/d09b4b57f3c5ed016caee1abefebe4c68f022232340c153a7c2a9595288b0333/68747470733a2f2f706f7365722e707567782e6f72672f616c656b7365792e6e656d69726f2f6e656d69726f2e646174612e7068702f646f776e6c6f616473)](https://packagist.org/packages/aleksey.nemiro/nemiro.data.php) [![License](https://camo.githubusercontent.com/e047cd4cf17c21130c941b097d4ee05c4ffbb289f648be79ceb75e5355b4b554/68747470733a2f2f706f7365722e707567782e6f72672f616c656b7365792e6e656d69726f2f6e656d69726f2e646174612e7068702f6c6963656e7365)](https://packagist.org/packages/aleksey.nemiro/nemiro.data.php)

[](#nemirodataphp---)

**Nemiro.Data.PHP** is a small set of utility classes for working with databases **MySql** and **PostgreSQL**.

To work with the databases used five simple methods: **ExecuteNonQuery**, **ExecuteScalar**, **GetData**, **GetTable** and **GetRow**.

The classes allow you to use parameterized queries, which makes working with databases secure.

**Nemiro.Data.PHP** is licensed under the **Apache License Version 2.0**.

### Features

[](#features)

- Client for MySql;
- Client for PostgreSQL;
- A single interface to work with different data providers;
- Automatic control of database connections;
- Parameterized queries.

### System Requirements

[](#system-requirements)

- PHP 5 &gt;= 5.3;
- MySQL &gt;= 5.6;
- PostgreSQL &gt;= 7.4.

**NOTE:** Working with the earlier versions just has not been tested.

### Supports

[](#supports)

Further support and development of the project is not planned. Welcome to **.NET** ;-)

### How to use the project?

[](#how-to-use-the-project)

The files of the project are made in **[Visual Studio 2013](https://www.visualstudio.com/)** with the extension **[PHP Tools for Visual Studio](https://visualstudiogallery.msdn.microsoft.com/6eb51f05-ef01-4513-ac83-4c5f50c95fb5)**.

To use the classes in your own projects, it is recommended to put all the solution files in a folder **\\Nemiro\\Data** (corresponds to the namespace).

### How to use the classes?

[](#how-to-use-the-classes)

#### Configuration

[](#configuration)

By default, classes use the database connection settings of the following constants:

```
// MySql
define('MYSQL_DB_NAME', '%your database name here%');
define('MYSQL_DB_USER', '%your database username here%');
define('MYSQL_DB_PASSWORD', '%your database password here%');
define('MYSQL_DB_HOST', 'localhost');
define('MYSQL_DB_PORT', 3306);
define('MYSQL_DB_MODE', 2);

// PostgreSQL
define('PGSQL_DB_NAME', '%your database name here%');
define('PGSQL_DB_USER', '%your database username here%');
define('PGSQL_DB_PASSWORD', '%your database password here%');
define('PGSQL_DB_HOST', 'localhost');
define('PGSQL_DB_PORT', 5432);
define('PGSQL_DB_MODE', 1);
```

The **DB\_MODE** may be one of the following:

- 0 - manual;
- 1 - auto - open and close for each request;
- 2 - smart (recomended).

You can use individual connection settings, which must be specified when you create an instance of a database client.

#### Including files

[](#including-files)

To use the database clients, you must include the following files:

```
require_once './Nemiro/Data/Import.php';
```

or

```
require_once './Nemiro/Data/MySql.php';
require_once './Nemiro/Data/PgSql.php';
```

#### Importing namespaces

[](#importing-namespaces)

For convenience, you can import the necessary classes in your code:

```
// client for MySql
use Nemiro\Data\MySql as MySql;
// client for PostgreSQL
use Nemiro\Data\PgSql as PgSql;
// query builder
use Nemiro\Data\DBCommand as DBCommand;
```

#### Examples of use

[](#examples-of-use)

The following example creates a simple query to select all records from the table `[messages]`.

Records obtained by the **GetTable** method, which returns an array of rows.

```
// create client instance for MySql
$client = new MySql();

// create a new command
$client->Command = new DBCommand('SELECT * FROM messages');

// get table
$table = $client->GetTable();

// output the table rows
echo '';
foreach($table as $row)
{
	print_r($row);
}
echo '';
```

The following example creates a parameterized query to add records to the table `[users]`.

The query is executed by the **ExecuteScalar** method, which returns the ID of added record.

```
// create client instance for MySql
$client = new MySql();

// create a new command
$client->Command = new DBCommand
(
	'INSERT INTO users (username, date_created) '.
	'VALUES (@username, @date_created)'
);

// @username and @date_created is parameters name,
// add a values for this parameters
$client->Command->Parameters->Add('@date_created')->SetValue(date('Y-m-d H-i-s'));
$client->Command->Parameters->Add('@username')->SetValue('anyname');

// execute the command
$newId = $client->ExecuteScalar();

echo 'ID = '.$newId;
```

The following example creates multiple queries and executed by the **GetData** method, which returns an array of tables.

```
// create client instance for MySql
$client = new MySql();

// create commands
$firtCommand = new DBCommand('SELECT * FROM users WHERE is_blocked = 0');

$secondCommand = new DBCommand
(
	'SELECT * FROM messages WHERE id_users IN '.
	'(SELECT id_users FROM users WHERE is_blocked = 0) AND '.
	'subject LIKE @search_subject'
);
$secondCommand->Parameters->Add('@search_subject', '%hello%');

$thirdCommand = 'SELECT * FROM files';

// etc...

// add commands to client
$client->Command = array($firtCommand, $secondCommand, $thirdCommand);

// and execute all command
$data = $client->GetData();

// output results

echo '';
foreach ($data as $table)
{
	print_r($table);
}
echo '';
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

3844d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c2475fd956b57400794960b56d5f8d44e106b5373e425c6ed2b2975d4756ce19?d=identicon)[aleksey.nemiro](/maintainers/aleksey.nemiro)

---

Top Contributors

[![alekseynemiro](https://avatars.githubusercontent.com/u/6204692?v=4)](https://github.com/alekseynemiro "alekseynemiro (11 commits)")

---

Tags

phpdatadatabasemysqlpostgresqlpgsql

### Embed Badge

![Health badge](/badges/alekseynemiro-nemirodataphp/health.svg)

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

###  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)[mevdschee/php-crud-api

Single file PHP script that adds a REST API to a SQL database.

3.7k63.8k9](/packages/mevdschee-php-crud-api)[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4572.9M34](/packages/aura-sqlquery)[vcian/laravel-db-auditor

Database DB Auditor provide leverage to audit your MySql,sqlite, PostgreSQL database standards and also provide options to add constraints in table.

28535.1k1](/packages/vcian-laravel-db-auditor)[atlas/query

Object-oriented query builders and performers for MySQL, Postgres, SQLite, and SQLServer.

41249.0k7](/packages/atlas-query)[aura/sqlschema

Provides facilities to read table names and table columns from a database using PDO.

41234.1k4](/packages/aura-sqlschema)

PHPackages © 2026

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