1. Go to this page and download the library: Download mnlnk/database library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mnlnk / database example snippets
use Manuylenko\DataBase\Connectors\MySQLConnector;
use Manuylenko\DataBase\DB;
$name = 'database';
$user = 'mnlnk';
$passwd = 'LvQ_]uP.OfxE!kFp';
$host = 'localhost';
$connector = new MySQLConnector($user, $passwd, $name, $host);
$db = new DB($connector);
// Получает одну запись
$stmt = $db->query('SELECT Album FROM Artists WHERE Singer = ?', [
'The Prodigy'
]);
$row = $stmt->fetch();
// Получает массив записей из таблицы
$stmt = $db->query('SELECT * FROM Artists');
$rows = $stmt->fetchAll();
// Добавляет запись в таблицу
$db->query('INSERT INTO * FROM Artists', [
'Singer' => 'The Prodigy',
'Album' => 'Music For The Jilted Generation',
'Year' => '1994',
'Sale' => 1500000
]);
// Получает экземпляр запроса для таблицы
$table = $db->getQueryInstanceForTable('Artists');
// Добавляет запись в таблицу
$table->insert([
'Singer' => 'The Prodigy',
'Album' => 'Music For The Jilted Generation',
'Year' => '1994',
'Sale' => 1500000
]);
// Получает массив записей из таблицы
$rows = $table
->column('Singer')
->where('Year', '>=', '1994')
->group('Singer')
->fetchColumn(0)
->select();
// Получает одну запись из таблицы
$row = $table
->column('Singer')
->where('Year', '>=', '2000')
->get();
// Обновляет запись в таблице
$table
->where('Id', '=', '73')
->update([
'Singer' => 'Massive Attack',
]);
// Удаляет запись из таблицы
$table
->where('Id', '=', '73')
->delete();
// Получает список выполненных запросов
$queries = DB::getQueries();
// Получает количество выполненных запросов
$countQueries = DB::getCountQueries();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.