PHPackages                             nouvu/lerma - 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. nouvu/lerma

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

nouvu/lerma
===========

Multi-screwdriver for the database Nouvu/Database

v7.2.4(4y ago)0861Apache-2.0PHPPHP &gt;=8.1

Since Mar 3Pushed 3y ago1 watchersCompare

[ Source](https://github.com/MouseZver/Lerma)[ Packagist](https://packagist.org/packages/nouvu/lerma)[ Docs](https://github.com/MouseZver/Lerma)[ RSS](/packages/nouvu-lerma/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (10)Dependencies (1)Versions (13)Used By (1)

Nouvu/Lerma
===========

[](#nouvulerma)

[![Latest Unstable Version](https://camo.githubusercontent.com/3c6cdcf4c1d62568b539b3101fcf309bbcf0860cc3bb5d78f3a4fe580215d8bb/68747470733a2f2f706f7365722e707567782e6f72672f6e6f7576752f6c65726d612f762f737461626c65)](https://packagist.org/packages/nouvu/lerma) [![License](https://camo.githubusercontent.com/4a24d7d70f993abf4c177923dd0f01d74c986dd833473315c76e7e0d647a7c75/68747470733a2f2f706f7365722e707567782e6f72672f6e6f7576752f6c65726d612f6c6963656e7365)](//packagist.org/packages/nouvu/lerma)

> This implementation uses modules without PDO

### Composer

[](#composer)

```
composer require nouvu/lerma:^7.2.4
```

Initial use
-----------

[](#initial-use)

#### \#1 - method

[](#1---method)

```
Lerma :: create ( DriverEnum $driver ): ConnectDataInterface
```

#### \#2 - method

[](#2---method)

```
new Lerma( string | array $dsn ): Lerma
```

Connect MySQLi Example
----------------------

[](#connect-mysqli-example)

#### \#1 - Static Lerma instance

[](#1---static-lerma-instance)

```
use Nouvu\Database\{ Lerma, DriverEnum };

require 'vendor/autoload.php';

$lerma = Lerma :: create( driver: DriverEnum :: MySQLi )
	-> setData( host: '127.0.0.1', username: 'root', password: 'root' )
	-> setDatabaseName( dbname: 'dbtest' )
	-> setCharset( charset: 'utf8' )
	-> setPort( port: 3306 )
	-> getLerma();
```

#### \#2 - Lerma instance

[](#2---lerma-instance)

```
use Nouvu\Database\Lerma;

require 'vendor/autoload.php';

// dsn can use sprintf
$lerma = new Lerma( [ 'mysql:host=%s;username=%s;password=%s;dbname=%s;charset=%s;port=%d',
    '127.0.0.1', 'root', 'root', 'dbtest', 'utf8', 3306
] );
```

Connect SQLite3 Example
-----------------------

[](#connect-sqlite3-example)

#### \#1 - Static Lerma instance

[](#1---static-lerma-instance-1)

```
use Nouvu\Database\{ Lerma, DriverEnum };

require 'vendor/autoload.php';

$lerma = Lerma :: create( driver: DriverEnum :: SQLite3 )
	-> setFile( __DIR__ . '/dbtest.db' )
	-> getLerma();
```

#### \#2 - Lerma instance

[](#2---lerma-instance-1)

```
use Nouvu\Database\Lerma;

require 'vendor/autoload.php';

// dsn can use sprintf
$lerma = new Lerma( [ 'sqlite:db=%s', __DIR__ . '/dbtest.db' ] );
```

---

Nouvu\\Database\\Lerma :: class
-------------------------------

[](#nouvudatabaselerma--class)

Contents spoiler#### Список методов

[](#список-методов)

Статический интерфейс подключения к Базе Данных

```
public static function create( DriverEnum $driver ): ConnectDataInterface
```

Подготавливает запрос к выполнению

```
public function prepare( string | array $sql, array $data = null ): LermaStatement
```

Выполняет запрос к базе данных

```
public function query( string | array $sql ): LermaStatement
```

Запускает подготовленный запрос на выполнение

```
public function execute( array $data ): void
```

Откат текущей транзакции

```
public function rollBack( mixed ...$rollback ): bool
```

Стартует транзакцию

```
public function beginTransaction( mixed ...$rollback ): bool
```

Фиксирует транзакцию

```
public function commit( mixed ...$commit ): bool
```

Возвращает значение, созданное для столбца AUTO\_INCREMENT последним запросом

```
public function InsertID(): int
```

#### Code Examples

[](#code-examples)

\#1 - example

```
$values = [ 'group' => 6, 'Lerma' ];

$statement = $lerma -> prepare( [ 'SELECT * FROM `%s` WHERE `group` = :group AND `name` = ?', 'table' ], $values );

echo json_encode ( $statement -> fetch( Lerma :: FETCH_ASSOC ), 480 );
```

```
{
	"id": 8,
	"name": "Lerma",
	"group": 6,
	"text": "Инструмент",
	"created_at": "2022-02-06 23:44:30"
}
```

\#2 - example

```
$values = [
	[ 'name1', 'group1', 'text1' ],
	[ 'name2', 'group2', 'text2' ],
	[ 'name3', 'group3', 'text3' ],
];

$lerma -> prepare( [ 'INSERT INTO `%s`( `name`, `group`, `text` ) VALUES ( ?,?,? )', 'table' ], $values );

echo $lerma -> InsertID(); // 3
```

OR

```
$values = [
	[ 'name1', 'group1', 'text1' ],
	[ 'name2', 'group2', 'text2' ],
	[ 'name3', 'group3', 'text3' ],
];

try
{
	$lerma -> beginTransaction();

	// uses rollBack if Exception
	$lerma -> prepare( [ 'INSERT INTO `%s`( `name`, `group`, `text` ) VALUES ( ?,?,? )', 'table' ], $values );

	$lerma -> commit();
}
catch ( \Nouvu\Database\Exception\LermaException )
{

}

// 2 ----------------

try
{
	$lerma -> beginTransaction();

	$lerma -> prepare( [ 'INSERT INTO `%s`( `name`, `group`, `text` ) VALUES ( ?,?,? )', 'table' ] );

	foreach ( $values AS $row )
	{
		$lerma -> execute( $row );
	}

	$lerma -> commit();

	echo $lerma -> InsertID(); // 3
}
catch ( \Nouvu\Database\Exception\LermaException )
{
	$lerma -> rollBack();
}
```

---

Nouvu\\Database\\LermaStatement :: class
----------------------------------------

[](#nouvudatabaselermastatement--class)

Contents spoiler#### Список методов

[](#список-методов-1)

Извлечение следующей строки из результирующего набора

```
public function fetch( int $mode = null, \Closure | string | null $argument = null ): mixed
```

Выбирает оставшиеся строки из набора результатов

```
public function fetchAll( int $mode = null, \Closure | string | null $argument = null ): iterable
```

Возвращает количество строк, затронутых последним SQL-запросом

```
public function rowCount(): int
```

Возвращает количество столбцов в результирующем наборе

```
public function columnCount(): int
```

Извлекает внешний итератор

```
public function getIterator(): \Traversable
```

> Только для MySQLi

#### Code Examples

[](#code-examples-1)

\#1 - example - iterator MySQLi

```
$statement = $lerma -> query( 'SELECT * ...' );

foreach ( $statement AS $row )
{
	// result $row
}

// OR

iterator_to_array ( $statement );
```

```
Array
(
    [0] => Array
        (
            [0] => 1
            [1] => Nouvu-Skeleton
            [2] => 1
            [3] => скелет
            [4] => 2022-02-06 23:44:30
        )

    [1] => Array
        (
            [0] => 2
            [1] => Nouvu-Framework
            [2] => 1
            [3] => ядро
            [4] => 2022-02-06 23:44:30
        )

    [2] => Array
        (
            [0] => 3
            [1] => Nouvu-Web
            [2] => 1
            [3] => веб
            [4] => 2022-02-06 23:44:30
        )

	...
)
```

\#2 - example - fetch(All)

```
$statement = $lerma -> query( 'SELECT `name` ...' );

while ( $value = $statement -> fetch( Lerma :: FETCH_COLUMN ) )
{
	// result #1
}

foreach ( $statement -> fetchAll( Lerma :: FETCH_COLUMN ) AS $value )
{
	// result #2
}
```

result #1 and #2

```
Nouvu-Skeleton
Nouvu-Framework
Nouvu-Web
ContainerPHP
Logger
Query-Storage-Bank
Neuronet
Lerma
McBanner
Piramid
Aero
Aero2
Aero-Authentication
```

\#3 - Новая возможность - FETCH\_FUNC from Generator

```
$statement = $lerma -> query( 'SELECT `name` ...' );

$statement -> fetchAll( Lerma :: FETCH_FUNC, function ( object $std ) )
{
	yield $std -> id => $std;
}
```

> Предупреждение:

```
'SELECT * FROM table LIMIT ?, ?'
```

> Вызовет ошибку как и в других случаях синтаксиса query. Используйте принудительно подстановку значений в запрос

Список режимов
--------------

[](#список-режимов)

namefetchfetchAllcodeLerma :: FETCH\_NUM++1Lerma :: FETCH\_ASSOC++2Lerma :: FETCH\_OBJ++4Lerma :: FETCH\_COLUMN++265Lerma :: FETCH\_FUNC++586Lerma :: FETCH\_KEY\_PAIR++307Lerma :: FETCH\_KEY\_PAIR | Lerma :: FETCH\_FUNC-+891Lerma :: FETCH\_UNIQUE-+333Lerma :: FETCH\_GROUP-+428Lerma :: FETCH\_GROUP | Lerma :: FETCH\_COLUMN-+429Lerma :: MYSQL\_FETCH\_FIELD++343Lerma :: MYSQL\_FETCH\_BIND+-663Lerma :: MYSQL\_FETCH\_BIND | Lerma :: FETCH\_COLUMN+-927Helper Functions
----------------

[](#helper-functions)

Contents spoilernamespace

```
use function Nouvu\Database\Helpers\{ ... };
```

Доступ к внутреннему файлу конфигурации

```
config( string $offset = null ): mixed
```

```
// Отключение именованных плейсхолдеров
config() -> set( 'namedPlaceholders', false );

// Установка режима вывода по умолчанию
config() -> set( 'mode', Lerma :: FETCH_OBJ );

// Вывод списка данных для подключения различных расширений
config( 'drivers' );
```

```
use Nouvu\Config\Config;
use Nouvu\Database\Lerma;
use Nouvu\Database\Modules;

return [
	'dsn_default' => 'mysql',
	'drivers' => [
		'mysql' => [
			'module' => Modules\MySQLi :: class,
			'dbname' => 'dbtest',
			'host' => '127.0.0.1',
			'port' => 3306,
			'charset' => 'utf8',
			'username' => 'root',
			'password' => 'root'
		],
		'sqlite' => [
			'module' => Modules\SQLite3 :: class,
			'db' => 'lerma.db'
		],
	],
	'mode' => Lerma :: FETCH_NUM,
	'namedPlaceholders' => true,
	'ShemaExceptionConnect' => [
		'mysql' => static function ( mysqli_sql_exception $mysqli_sql_exception )
		{
			throw $mysqli_sql_exception;
		},
	],
	\Facade\Create :: class => [
		'mysql' => \Nouvu\Database\Modules\Facade\Mysql\ConnectData :: class,
		'sqlite' => \Nouvu\Database\Modules\Facade\Sqlite\ConnectData :: class,
	],
]
```

Debug строки запроса и значений

```
debug( bool $reset = false ): Debug
```

```
echo json_encode ( debug(), 480 );
```

Прямой доступ к расширению
--------------------------

[](#прямой-доступ-к-расширению)

```
$connect = $lerma -> connect() -> get();
```

Fetch mode Result Examples
--------------------------

[](#fetch-mode-result-examples)

Lerma :: FETCH\_NUM```
$stmt = $lerma -> query( [ 'SELECT * FROM `%s`', $this -> table ] );

print_r ( $stmt -> fetch( Lerma :: FETCH_NUM ) );
```

```
Array
(
    [0] => 1
    [1] => Nouvu-Skeleton
    [2] => 1
    [3] => скелет
    [4] => 2022-02-06 23:44:30
)
```

```
$stmt = $lerma -> query( [ 'SELECT * FROM `%s`', $this -> table ] );

print_r ( $stmt -> fetchAll( Lerma :: FETCH_NUM ) );
```

```
Array
(
    [0] => Array
        (
            [0] => 1
            [1] => Nouvu-Skeleton
            [2] => 1
            [3] => скелет
            [4] => 2022-02-06 23:44:30
        )

    [1] => Array
        (
            [0] => 2
            [1] => Nouvu-Framework
            [2] => 1
            [3] => ядро
            [4] => 2022-02-06 23:44:30
        )

    [2] => Array
        (
            [0] => 3
            [1] => Nouvu-Web
            [2] => 1
            [3] => веб
            [4] => 2022-02-06 23:44:30
        )

    [3] => Array
        (
            [0] => 4
            [1] => ContainerPHP
            [2] => 2
            [3] => ленивая загрузка
            [4] => 2022-02-06 23:44:30
        )

    [4] => Array
        (
            [0] => 5
            [1] => Logger
            [2] => 3
            [3] => логирование
            [4] => 2022-02-06 23:44:30
        )

    [5] => Array
        (
            [0] => 6
            [1] => Query-Storage-Bank
            [2] => 4
            [3] => хранимые процедуры
            [4] => 2022-02-06 23:44:30
        )

    [6] => Array
        (
            [0] => 7
            [1] => Neuronet
            [2] => 5
            [3] => Нейросеть
            [4] => 2022-02-06 23:44:30
        )

    [7] => Array
        (
            [0] => 8
            [1] => Lerma
            [2] => 6
            [3] => Инструмент
            [4] => 2022-02-06 23:44:30
        )

    [8] => Array
        (
            [0] => 9
            [1] => McBanner
            [2] => 7
            [3] => Счетчик
            [4] => 2022-02-06 23:44:30
        )

    [9] => Array
        (
            [0] => 10
            [1] => Piramid
            [2] => 7
            [3] => Пирамида цветная
            [4] => 2022-02-06 23:44:30
        )

    [10] => Array
        (
            [0] => 11
            [1] => Aero
            [2] => 8
            [3] => старое ядро
            [4] => 2022-02-06 23:44:30
        )

    [11] => Array
        (
            [0] => 12
            [1] => Aero2
            [2] => 8
            [3] => старое ядро2
            [4] => 2022-02-06 23:44:30
        )

    [12] => Array
        (
            [0] => 13
            [1] => Aero-Authentication
            [2] => 9
            [3] => в мусор
            [4] => 2022-02-06 23:44:30
        )

)
```

Lerma :: FETCH\_ASSOC```
$stmt = $lerma -> query( [ 'SELECT * FROM `%s`', $this -> table ] );

print_r ( $stmt -> fetch( Lerma :: FETCH_ASSOC ) );
```

```
Array
(
    [id] => 1
    [name] => Nouvu-Skeleton
    [group] => 1
    [text] => скелет
    [created_at] => 2022-02-06 23:44:30
)
```

```
$stmt = $lerma -> query( [ 'SELECT * FROM `%s`', $this -> table ] );

print_r ( $stmt -> fetchAll( Lerma :: FETCH_ASSOC ) );
```

```
Array
(
    [0] => Array
        (
            [id] => 1
            [name] => Nouvu-Skeleton
            [group] => 1
            [text] => скелет
            [created_at] => 2022-02-06 23:44:30
        )

    [1] => Array
        (
            [id] => 2
            [name] => Nouvu-Framework
            [group] => 1
            [text] => ядро
            [created_at] => 2022-02-06 23:44:30
        )

    [2] => Array
        (
            [id] => 3
            [name] => Nouvu-Web
            [group] => 1
            [text] => веб
            [created_at] => 2022-02-06 23:44:30
        )

    [3] => Array
        (
            [id] => 4
            [name] => ContainerPHP
            [group] => 2
            [text] => ленивая загрузка
            [created_at] => 2022-02-06 23:44:30
        )

    [4] => Array
        (
            [id] => 5
            [name] => Logger
            [group] => 3
            [text] => логирование
            [created_at] => 2022-02-06 23:44:30
        )

    [5] => Array
        (
            [id] => 6
            [name] => Query-Storage-Bank
            [group] => 4
            [text] => хранимые процедуры
            [created_at] => 2022-02-06 23:44:30
        )

    [6] => Array
        (
            [id] => 7
            [name] => Neuronet
            [group] => 5
            [text] => Нейросеть
            [created_at] => 2022-02-06 23:44:30
        )

    [7] => Array
        (
            [id] => 8
            [name] => Lerma
            [group] => 6
            [text] => Инструмент
            [created_at] => 2022-02-06 23:44:30
        )

    [8] => Array
        (
            [id] => 9
            [name] => McBanner
            [group] => 7
            [text] => Счетчик
            [created_at] => 2022-02-06 23:44:30
        )

    [9] => Array
        (
            [id] => 10
            [name] => Piramid
            [group] => 7
            [text] => Пирамида цветная
            [created_at] => 2022-02-06 23:44:30
        )

    [10] => Array
        (
            [id] => 11
            [name] => Aero
            [group] => 8
            [text] => старое ядро
            [created_at] => 2022-02-06 23:44:30
        )

    [11] => Array
        (
            [id] => 12
            [name] => Aero2
            [group] => 8
            [text] => старое ядро2
            [created_at] => 2022-02-06 23:44:30
        )

    [12] => Array
        (
            [id] => 13
            [name] => Aero-Authentication
            [group] => 9
            [text] => в мусор
            [created_at] => 2022-02-06 23:44:30
        )

)
```

Lerma :: FETCH\_OBJ```
$stmt = $lerma -> query( [ 'SELECT * FROM `%s`', $this -> table ] );

print_r ( $stmt -> fetch( Lerma :: FETCH_OBJ ) );
```

```
stdClass Object
(
    [id] => 1
    [name] => Nouvu-Skeleton
    [group] => 1
    [text] => скелет
    [created_at] => 2022-02-06 23:44:30
)
```

```
$stmt = $lerma -> query( [ 'SELECT * FROM `%s`', $this -> table ] );

print_r ( $stmt -> fetchAll( Lerma :: FETCH_OBJ ) );
```

```
Array
(
    [0] => stdClass Object
        (
            [id] => 1
            [name] => Nouvu-Skeleton
            [group] => 1
            [text] => скелет
            [created_at] => 2022-02-06 23:44:30
        )

    [1] => stdClass Object
        (
            [id] => 2
            [name] => Nouvu-Framework
            [group] => 1
            [text] => ядро
            [created_at] => 2022-02-06 23:44:30
        )

    [2] => stdClass Object
        (
            [id] => 3
            [name] => Nouvu-Web
            [group] => 1
            [text] => веб
            [created_at] => 2022-02-06 23:44:30
        )

    [3] => stdClass Object
        (
            [id] => 4
            [name] => ContainerPHP
            [group] => 2
            [text] => ленивая загрузка
            [created_at] => 2022-02-06 23:44:30
        )

    [4] => stdClass Object
        (
            [id] => 5
            [name] => Logger
            [group] => 3
            [text] => логирование
            [created_at] => 2022-02-06 23:44:30
        )

    [5] => stdClass Object
        (
            [id] => 6
            [name] => Query-Storage-Bank
            [group] => 4
            [text] => хранимые процедуры
            [created_at] => 2022-02-06 23:44:30
        )

    [6] => stdClass Object
        (
            [id] => 7
            [name] => Neuronet
            [group] => 5
            [text] => Нейросеть
            [created_at] => 2022-02-06 23:44:30
        )

    [7] => stdClass Object
        (
            [id] => 8
            [name] => Lerma
            [group] => 6
            [text] => Инструмент
            [created_at] => 2022-02-06 23:44:30
        )

    [8] => stdClass Object
        (
            [id] => 9
            [name] => McBanner
            [group] => 7
            [text] => Счетчик
            [created_at] => 2022-02-06 23:44:30
        )

    [9] => stdClass Object
        (
            [id] => 10
            [name] => Piramid
            [group] => 7
            [text] => Пирамида цветная
            [created_at] => 2022-02-06 23:44:30
        )

    [10] => stdClass Object
        (
            [id] => 11
            [name] => Aero
            [group] => 8
            [text] => старое ядро
            [created_at] => 2022-02-06 23:44:30
        )

    [11] => stdClass Object
        (
            [id] => 12
            [name] => Aero2
            [group] => 8
            [text] => старое ядро2
            [created_at] => 2022-02-06 23:44:30
        )

    [12] => stdClass Object
        (
            [id] => 13
            [name] => Aero-Authentication
            [group] => 9
            [text] => в мусор
            [created_at] => 2022-02-06 23:44:30
        )

)
```

Lerma :: FETCH\_COLUMN```
$stmt = $lerma -> query( [ 'SELECT `name` FROM `%s`', $this -> table ] );

print_r ( $stmt -> fetch( Lerma :: FETCH_COLUMN ) );
```

```
Nouvu-Skeleton
```

```
$stmt = $lerma -> query( [ 'SELECT `name` FROM `%s`', $this -> table ] );

print_r ( $stmt -> fetchAll( Lerma :: FETCH_COLUMN ) );
```

```
Array
(
    [0] => Nouvu-Skeleton
    [1] => Nouvu-Framework
    [2] => Nouvu-Web
    [3] => ContainerPHP
    [4] => Logger
    [5] => Query-Storage-Bank
    [6] => Neuronet
    [7] => Lerma
    [8] => McBanner
    [9] => Piramid
    [10] => Aero
    [11] => Aero2
    [12] => Aero-Authentication
)
```

Lerma :: FETCH\_FUNC```
$stmt = $lerma -> query( [ 'SELECT * FROM `%s`', $this -> table ] );

print_r ( $stmt -> fetch( Lerma :: FETCH_FUNC, function ( object $data ): string
{
	return implode ( ' - ', ( array ) $data );
} ) );
```

```
1 - Nouvu-Skeleton - 1 - скелет - 2022-02-06 23:44:30
```

```
$stmt = $lerma -> query( [ 'SELECT * FROM `%s`', $this -> table ] );

print_r ( $stmt -> fetchAll( Lerma :: FETCH_FUNC, function ( object $data ): string
{
	return implode ( ' - ', ( array ) $data );
} ) );
```

```
Array
(
    [0] => 1 - Nouvu-Skeleton - 1 - скелет - 2022-02-06 23:44:30
    [1] => 2 - Nouvu-Framework - 1 - ядро - 2022-02-06 23:44:30
    [2] => 3 - Nouvu-Web - 1 - веб - 2022-02-06 23:44:30
    [3] => 4 - ContainerPHP - 2 - ленивая загрузка - 2022-02-06 23:44:30
    [4] => 5 - Logger - 3 - логирование - 2022-02-06 23:44:30
    [5] => 6 - Query-Storage-Bank - 4 - хранимые процедуры - 2022-02-06 23:44:30
    [6] => 7 - Neuronet - 5 - Нейросеть - 2022-02-06 23:44:30
    [7] => 8 - Lerma - 6 - Инструмент - 2022-02-06 23:44:30
    [8] => 9 - McBanner - 7 - Счетчик - 2022-02-06 23:44:30
    [9] => 10 - Piramid - 7 - Пирамида цветная - 2022-02-06 23:44:30
    [10] => 11 - Aero - 8 - старое ядро - 2022-02-06 23:44:30
    [11] => 12 - Aero2 - 8 - старое ядро2 - 2022-02-06 23:44:30
    [12] => 13 - Aero-Authentication - 9 - в мусор - 2022-02-06 23:44:30
)
```

Возможность - Generator

```
$statement = $lerma -> query( 'SELECT `name` ...' );

$statement -> fetchAll( Lerma :: FETCH_FUNC, function ( object $data ) ): iterable
{
	yield $data -> id => $data;
}
```

Lerma :: FETCH\_KEY\_PAIR```
$stmt = $lerma -> query( [ 'SELECT `name`, `text` FROM `%s`', $this -> table ] );

print_r ( $stmt -> fetch( Lerma :: FETCH_KEY_PAIR ) );
```

```
Array
(
    [Nouvu-Skeleton] => скелет
)
```

```
$stmt = $lerma -> query( [ 'SELECT `name`, `text` FROM `%s`', $this -> table ] );

print_r ( $stmt -> fetchAll( Lerma :: FETCH_KEY_PAIR ) );
```

```
Array
(
    [Nouvu-Skeleton] => скелет
    [Nouvu-Framework] => ядро
    [Nouvu-Web] => веб
    [ContainerPHP] => ленивая загрузка
    [Logger] => логирование
    [Query-Storage-Bank] => хранимые процедуры
    [Neuronet] => Нейросеть
    [Lerma] => Инструмент
    [McBanner] => Счетчик
    [Piramid] => Пирамида цветная
    [Aero] => старое ядро
    [Aero2] => старое ядро2
    [Aero-Authentication] => в мусор
)
```

Lerma :: FETCH\_KEY\_PAIR | Lerma :: FETCH\_FUNC```
$stmt = $lerma -> query( [ 'SELECT `name`, `text` FROM `%s`', $this -> table ] );

print_r ( $stmt -> fetchAll( Lerma :: FETCH_KEY_PAIR | Lerma :: FETCH_FUNC, function ( string $first, string $second ): string
{
	return "--- {{$first} | {$second}} ---";
} ) );
```

```
Array
(
    [Nouvu-Skeleton] => --- {Nouvu-Skeleton | скелет} ---
    [Nouvu-Framework] => --- {Nouvu-Framework | ядро} ---
    [Nouvu-Web] => --- {Nouvu-Web | веб} ---
    [ContainerPHP] => --- {ContainerPHP | ленивая загрузка} ---
    [Logger] => --- {Logger | логирование} ---
    [Query-Storage-Bank] => --- {Query-Storage-Bank | хранимые процедуры} ---
    [Neuronet] => --- {Neuronet | Нейросеть} ---
    [Lerma] => --- {Lerma | Инструмент} ---
    [McBanner] => --- {McBanner | Счетчик} ---
    [Piramid] => --- {Piramid | Пирамида цветная} ---
    [Aero] => --- {Aero | старое ядро} ---
    [Aero2] => --- {Aero2 | старое ядро2} ---
    [Aero-Authentication] => --- {Aero-Authentication | в мусор} ---
)
```

Lerma :: FETCH\_UNIQUE```
$stmt = $lerma -> query( [ 'SELECT * FROM `%s`', $this -> table ] );

print_r ( $stmt -> fetchAll( Lerma :: FETCH_UNIQUE, 'group' ) );
```

```
Array
(
    [1] => stdClass Object
        (
            [id] => 3
            [name] => Nouvu-Web
            [group] => 1
            [text] => веб
            [created_at] => 2022-02-06 23:44:30
        )

    [2] => stdClass Object
        (
            [id] => 4
            [name] => ContainerPHP
            [group] => 2
            [text] => ленивая загрузка
            [created_at] => 2022-02-06 23:44:30
        )

    [3] => stdClass Object
        (
            [id] => 5
            [name] => Logger
            [group] => 3
            [text] => логирование
            [created_at] => 2022-02-06 23:44:30
        )

    [4] => stdClass Object
        (
            [id] => 6
            [name] => Query-Storage-Bank
            [group] => 4
            [text] => хранимые процедуры
            [created_at] => 2022-02-06 23:44:30
        )

    [5] => stdClass Object
        (
            [id] => 7
            [name] => Neuronet
            [group] => 5
            [text] => Нейросеть
            [created_at] => 2022-02-06 23:44:30
        )

    [6] => stdClass Object
        (
            [id] => 8
            [name] => Lerma
            [group] => 6
            [text] => Инструмент
            [created_at] => 2022-02-06 23:44:30
        )

    [7] => stdClass Object
        (
            [id] => 10
            [name] => Piramid
            [group] => 7
            [text] => Пирамида цветная
            [created_at] => 2022-02-06 23:44:30
        )

    [8] => stdClass Object
        (
            [id] => 12
            [name] => Aero2
            [group] => 8
            [text] => старое ядро2
            [created_at] => 2022-02-06 23:44:30
        )

    [9] => stdClass Object
        (
            [id] => 13
            [name] => Aero-Authentication
            [group] => 9
            [text] => в мусор
            [created_at] => 2022-02-06 23:44:30
        )

)
```

Lerma :: FETCH\_GROUP```
$stmt = $lerma -> query( [ 'SELECT * FROM `%s`', $this -> table ] );

print_r ( $stmt -> fetchAll( Lerma :: FETCH_GROUP, 'group' ) );
```

```
Array
(
    [1] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 1
                    [name] => Nouvu-Skeleton
                    [group] => 1
                    [text] => скелет
                    [created_at] => 2022-02-06 23:44:30
                )

            [1] => stdClass Object
                (
                    [id] => 2
                    [name] => Nouvu-Framework
                    [group] => 1
                    [text] => ядро
                    [created_at] => 2022-02-06 23:44:30
                )

            [2] => stdClass Object
                (
                    [id] => 3
                    [name] => Nouvu-Web
                    [group] => 1
                    [text] => веб
                    [created_at] => 2022-02-06 23:44:30
                )

        )

    [2] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 4
                    [name] => ContainerPHP
                    [group] => 2
                    [text] => ленивая загрузка
                    [created_at] => 2022-02-06 23:44:30
                )

        )

    [3] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 5
                    [name] => Logger
                    [group] => 3
                    [text] => логирование
                    [created_at] => 2022-02-06 23:44:30
                )

        )

    [4] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 6
                    [name] => Query-Storage-Bank
                    [group] => 4
                    [text] => хранимые процедуры
                    [created_at] => 2022-02-06 23:44:30
                )

        )

    [5] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 7
                    [name] => Neuronet
                    [group] => 5
                    [text] => Нейросеть
                    [created_at] => 2022-02-06 23:44:30
                )

        )

    [6] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 8
                    [name] => Lerma
                    [group] => 6
                    [text] => Инструмент
                    [created_at] => 2022-02-06 23:44:30
                )

        )

    [7] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 9
                    [name] => McBanner
                    [group] => 7
                    [text] => Счетчик
                    [created_at] => 2022-02-06 23:44:30
                )

            [1] => stdClass Object
                (
                    [id] => 10
                    [name] => Piramid
                    [group] => 7
                    [text] => Пирамида цветная
                    [created_at] => 2022-02-06 23:44:30
                )

        )

    [8] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 11
                    [name] => Aero
                    [group] => 8
                    [text] => старое ядро
                    [created_at] => 2022-02-06 23:44:30
                )

            [1] => stdClass Object
                (
                    [id] => 12
                    [name] => Aero2
                    [group] => 8
                    [text] => старое ядро2
                    [created_at] => 2022-02-06 23:44:30
                )

        )

    [9] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 13
                    [name] => Aero-Authentication
                    [group] => 9
                    [text] => в мусор
                    [created_at] => 2022-02-06 23:44:30
                )

        )

)
```

Lerma :: FETCH\_GROUP | Lerma :: FETCH\_COLUMN```
$stmt = $lerma -> query( [ 'SELECT `group`, `name` FROM `%s`', $this -> table ] );

print_r ( $stmt -> fetchAll( Lerma :: FETCH_GROUP | Lerma :: FETCH_COLUMN ) );
```

```
Array
(
    [1] => Array
        (
            [0] => Nouvu-Skeleton
            [1] => Nouvu-Framework
            [2] => Nouvu-Web
        )

    [2] => Array
        (
            [0] => ContainerPHP
        )

    [3] => Array
        (
            [0] => Logger
        )

    [4] => Array
        (
            [0] => Query-Storage-Bank
        )

    [5] => Array
        (
            [0] => Neuronet
        )

    [6] => Array
        (
            [0] => Lerma
        )

    [7] => Array
        (
            [0] => McBanner
            [1] => Piramid
        )

    [8] => Array
        (
            [0] => Aero
            [1] => Aero2
        )

    [9] => Array
        (
            [0] => Aero-Authentication
        )

)
```

Lerma :: MYSQL\_FETCH\_FIELD```
$stmt = $lerma -> query( [ 'SELECT * FROM `%s`', $this -> table ] );

print_r ( $stmt -> fetch( Lerma :: MYSQL_FETCH_FIELD ) );
```

```
stdClass Object
(
    [name] => id
    [orgname] => id
    [table] => github_test
    [orgtable] => github_test
    [def] =>
    [db] => dbtest
    [catalog] => def
    [max_length] => 0
    [length] => 11
    [charsetnr] => 63
    [flags] => 49667
    [type] => 3
    [decimals] => 0
)
```

```
$stmt = $lerma -> query( [ 'SELECT * FROM `%s`', $this -> table ] );

print_r ( $stmt -> fetchAll( Lerma :: MYSQL_FETCH_FIELD ) );
```

```
Array
(
    [0] => stdClass Object
        (
            [name] => id
            [orgname] => id
            [table] => github_test
            [orgtable] => github_test
            [def] =>
            [db] => dbtest
            [catalog] => def
            [max_length] => 0
            [length] => 11
            [charsetnr] => 63
            [flags] => 49667
            [type] => 3
            [decimals] => 0
        )

    [1] => stdClass Object
        (
            [name] => name
            [orgname] => name
            [table] => github_test
            [orgtable] => github_test
            [def] =>
            [db] => dbtest
            [catalog] => def
            [max_length] => 0
            [length] => 196605
            [charsetnr] => 33
            [flags] => 4113
            [type] => 252
            [decimals] => 0
        )

    [2] => stdClass Object
        (
            [name] => group
            [orgname] => group
            [table] => github_test
            [orgtable] => github_test
            [def] =>
            [db] => dbtest
            [catalog] => def
            [max_length] => 0
            [length] => 11
            [charsetnr] => 63
            [flags] => 36865
            [type] => 3
            [decimals] => 0
        )

    [3] => stdClass Object
        (
            [name] => text
            [orgname] => text
            [table] => github_test
            [orgtable] => github_test
            [def] =>
            [db] => dbtest
            [catalog] => def
            [max_length] => 0
            [length] => 196605
            [charsetnr] => 33
            [flags] => 16
            [type] => 252
            [decimals] => 0
        )

    [4] => stdClass Object
        (
            [name] => created_at
            [orgname] => created_at
            [table] => github_test
            [orgtable] => github_test
            [def] =>
            [db] => dbtest
            [catalog] => def
            [max_length] => 0
            [length] => 19
            [charsetnr] => 63
            [flags] => 129
            [type] => 12
            [decimals] => 0
        )

)
```

Lerma :: MYSQL\_FETCH\_BIND```
$stmt = $lerma -> prepare( [ 'SELECT * FROM `%s` WHERE ?', $this -> table ], [ 1 ] );

print_r ( $stmt -> fetch( Lerma :: MYSQL_FETCH_BIND ) );
```

```
Array
(
    [0] => 1
    [1] => Nouvu-Skeleton
    [2] => 1
    [3] => скелет
    [4] => 2022-02-06 23:44:30
)
```

Lerma :: MYSQL\_FETCH\_BIND | Lerma :: FETCH\_COLUMN```
$stmt = $lerma -> prepare( [ 'SELECT `name` FROM `%s` WHERE ?', $this -> table ], [ 1 ] );

print_r ( $stmt -> fetch( Lerma :: MYSQL_FETCH_BIND | Lerma :: FETCH_COLUMN ) );
```

```
Nouvu-Skeleton
```

---

Create by [MouseZver](//php.ru/forum/members/40235)

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity79

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

Recently: every ~102 days

Total

12

Last Release

1497d ago

Major Versions

v1.1.2.1 → v6.02020-07-17

v6.1.0.0 → v7.0.0.52021-06-19

PHP version history (5 changes)v1.1.1PHP &gt;=7.1

v1.1.2PHP &gt;=7.0

v6.0PHP &gt;=7.4

v7.0.0.5PHP &gt;=8.0

v7.2.1PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/101aadda0f8f67a3fe83cd805856f28aa317c8591667758d30e67ba1ef6ea53c?d=identicon)[MouseZver](/maintainers/MouseZver)

---

Top Contributors

[![MouseZver](https://avatars.githubusercontent.com/u/28458679?v=4)](https://github.com/MouseZver "MouseZver (159 commits)")

---

Tags

databasemysqliphp8databaseiteratormysqlisqlite3php 8.1

### Embed Badge

![Health badge](/badges/nouvu-lerma/health.svg)

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

###  Alternatives

[ezsql/ezsql

Advance database access library. Make interacting with a database ridiculously easy. An universal interchangeable CRUD system.

86946.7k](/packages/ezsql-ezsql)[jv2222/ezsql

Advance database access library. Make interacting with a database ridiculously easy. An universal interchangeable CRUD system.

87311.3k2](/packages/jv2222-ezsql)[aplus/database

Aplus Framework Database Library

3331.6M7](/packages/aplus-database)[sergeytsalkov/meekrodb

The Simple PHP/MySQL Library

341387.0k10](/packages/sergeytsalkov-meekrodb)[stefangabos/zebra_session

A drop-in replacement for PHP's default session handler which stores session data in a MySQL database, providing better performance, better security and protection against session fixation and session hijacking

174112.1k2](/packages/stefangabos-zebra-session)[lincanbin/php-pdo-mysql-class

A PHP MySQL PDO class similar to the Python MySQLdb, which supports iterator and parameter binding when using 'WHERE IN' statement.

2386.4k](/packages/lincanbin-php-pdo-mysql-class)

PHPackages © 2026

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