Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dbal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ Idea by [@tharos](https://github.com/dg/db) (http://forum.nette.org/cs/viewtopic

### ORM

- CycleORM [~1.0, ~2.0]
- Doctrine2 [~2.4]
- LeanMapper [~2.0]
- NextrasOrm [~1.0]
- YetORM [~8.0]

### DBAL (Database Abstraction Layer)

- Dibi [~3.0, ~4.0, ~5.0]
- NextrasDbal [~3.0, ~4.0, ~5.0]

### ActiveRecord

- Nette Database [~2.0, ~2.1, ~2.2, ~2.3, master]
Expand Down
7 changes: 7 additions & 0 deletions dbal/cycle-orm/v1.0/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"require": {
"php": ">= 7.2",
"cycle/orm": "^1.0",
"cycle/database": "^1.0"
}
}
73 changes: 73 additions & 0 deletions dbal/cycle-orm/v1.0/run-employees.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

use Cycle\Database\Config\DatabaseConfig;
use Cycle\Database\Config\MySQLDriverConfig;
use Cycle\Database\DatabaseManager;

require_once __DIR__ . '/../../bootstrap.php';

Bootstrap::php('CycleORM (~1.0)', '>=', '7.2.0');
Bootstrap::init();
Bootstrap::check(__DIR__);

$config = Bootstrap::$config['db'];
$dbal = new DatabaseManager(
new DatabaseConfig([
'default' => 'default',
'databases' => [
'default' => ['connection' => 'mysql']
],
'connections' => [
'mysql' => new MySQLDriverConfig(
connection: new \Cycle\Database\Config\MySQL\TcpConnectionConfig(
database: $config['dbname'],
host: 'localhost',
port: 3306,
user: $config['user'],
password: $config['password'],
),
),
]
])
);

$db = $dbal->database('default');

$startTime = -microtime(TRUE);
ob_start();

$employees = $db->select()
->from('employees')
->columns(['emp_no', 'first_name', 'last_name'])
->limit(Bootstrap::$config['limit'])
->fetchAll();

foreach ($employees as $employee) {
echo "{$employee['first_name']} {$employee['last_name']} ({$employee['emp_no']})\n";

echo "Salaries:\n";
$salaries = $db->select()
->from('salaries')
->columns(['salary'])
->where('emp_no', '=', $employee['emp_no'])
->fetchAll();
foreach ($salaries as $salary) {
echo $salary['salary'], "\n";
}

echo "Departments:\n";
$departments = $db->select()
->from('dept_emp', 'de')
->innerJoin('departments', 'd')->on('d.dept_no', 'de.dept_no')
->columns(['d.dept_name'])
->where('de.emp_no', '=', $employee['emp_no'])
->fetchAll();
foreach ($departments as $department) {
echo $department['dept_name'], "\n";
}
}

ob_end_clean();
$endTime = microtime(TRUE);

Bootstrap::result('CycleORM', '~1.0', $startTime, $endTime);
7 changes: 7 additions & 0 deletions dbal/cycle-orm/v2.0/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"require": {
"php": ">= 8.0",
"cycle/orm": "^2.0",
"cycle/database": "^2.0"
}
}
73 changes: 73 additions & 0 deletions dbal/cycle-orm/v2.0/run-employees.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

use Cycle\Database\Config\DatabaseConfig;
use Cycle\Database\Config\MySQLDriverConfig;
use Cycle\Database\DatabaseManager;

require_once __DIR__ . '/../../bootstrap.php';

Bootstrap::php('CycleORM (~2.0)', '>=', '8.0.0');
Bootstrap::init();
Bootstrap::check(__DIR__);

$config = Bootstrap::$config['db'];
$dbal = new DatabaseManager(
new DatabaseConfig([
'default' => 'default',
'databases' => [
'default' => ['connection' => 'mysql']
],
'connections' => [
'mysql' => new MySQLDriverConfig(
connection: new \Cycle\Database\Config\MySQL\TcpConnectionConfig(
database: $config['dbname'],
host: 'localhost',
port: 3306,
user: $config['user'],
password: $config['password'],
),
),
]
])
);

$db = $dbal->database('default');

$startTime = -microtime(TRUE);
ob_start();

$employees = $db->select()
->from('employees')
->columns(['emp_no', 'first_name', 'last_name'])
->limit(Bootstrap::$config['limit'])
->fetchAll();

foreach ($employees as $employee) {
echo "{$employee['first_name']} {$employee['last_name']} ({$employee['emp_no']})\n";

echo "Salaries:\n";
$salaries = $db->select()
->from('salaries')
->columns(['salary'])
->where('emp_no', '=', $employee['emp_no'])
->fetchAll();
foreach ($salaries as $salary) {
echo $salary['salary'], "\n";
}

echo "Departments:\n";
$departments = $db->select()
->from('dept_emp', 'de')
->innerJoin('departments', 'd')->on('d.dept_no', 'de.dept_no')
->columns(['d.dept_name'])
->where('de.emp_no', '=', $employee['emp_no'])
->fetchAll();
foreach ($departments as $department) {
echo $department['dept_name'], "\n";
}
}

ob_end_clean();
$endTime = microtime(TRUE);

Bootstrap::result('CycleORM', '~2.0', $startTime, $endTime);
6 changes: 6 additions & 0 deletions dbal/dibi/v3.0/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"require": {
"php": ">= 5.6",
"dibi/dibi": "^3.0"
}
}
57 changes: 57 additions & 0 deletions dbal/dibi/v3.0/run-employees.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

use Dibi\Connection;

require_once __DIR__ . '/../../bootstrap.php';

Bootstrap::php('Dibi (~3.0)', '>=', '5.6.0');
Bootstrap::init();
Bootstrap::check(__DIR__);

$config = Bootstrap::$config['db'];
$connection = new Connection([
'driver' => 'mysqli',
'host' => 'localhost',
'database' => $config['dbname'],
'username' => $config['user'],
'password' => $config['password'],
]);

$startTime = -microtime(TRUE);
ob_start();

$employees = $connection->query('
SELECT emp_no, first_name, last_name
FROM employees
LIMIT %i', Bootstrap::$config['limit']
);

foreach ($employees as $employee) {
echo "{$employee->first_name} {$employee->last_name} ({$employee->emp_no})\n";

echo "Salaries:\n";
$salaries = $connection->query('
SELECT salary
FROM salaries
WHERE emp_no = %i', $employee->emp_no
);
foreach ($salaries as $salary) {
echo $salary->salary, "\n";
}

echo "Departments:\n";
$departments = $connection->query('
SELECT d.dept_name
FROM dept_emp de
JOIN departments d ON d.dept_no = de.dept_no
WHERE de.emp_no = %i', $employee->emp_no
);
foreach ($departments as $department) {
echo $department->dept_name, "\n";
}
}

ob_end_clean();
$endTime = microtime(TRUE);

Bootstrap::result('Dibi', '~3.0', $startTime, $endTime);
6 changes: 6 additions & 0 deletions dbal/dibi/v4.0/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"require": {
"php": ">= 7.1",
"dibi/dibi": "^4.0"
}
}
57 changes: 57 additions & 0 deletions dbal/dibi/v4.0/run-employees.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

use Dibi\Connection;

require_once __DIR__ . '/../../bootstrap.php';

Bootstrap::php('Dibi (~4.0)', '>=', '7.1.0');
Bootstrap::init();
Bootstrap::check(__DIR__);

$config = Bootstrap::$config['db'];
$connection = new Connection([
'driver' => 'mysqli',
'host' => 'localhost',
'database' => $config['dbname'],
'username' => $config['user'],
'password' => $config['password'],
]);

$startTime = -microtime(TRUE);
ob_start();

$employees = $connection->query('
SELECT emp_no, first_name, last_name
FROM employees
LIMIT %i', Bootstrap::$config['limit']
);

foreach ($employees as $employee) {
echo "{$employee->first_name} {$employee->last_name} ({$employee->emp_no})\n";

echo "Salaries:\n";
$salaries = $connection->query('
SELECT salary
FROM salaries
WHERE emp_no = %i', $employee->emp_no
);
foreach ($salaries as $salary) {
echo $salary->salary, "\n";
}

echo "Departments:\n";
$departments = $connection->query('
SELECT d.dept_name
FROM dept_emp de
JOIN departments d ON d.dept_no = de.dept_no
WHERE de.emp_no = %i', $employee->emp_no
);
foreach ($departments as $department) {
echo $department->dept_name, "\n";
}
}

ob_end_clean();
$endTime = microtime(TRUE);

Bootstrap::result('Dibi', '~4.0', $startTime, $endTime);
6 changes: 6 additions & 0 deletions dbal/dibi/v5.0/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"require": {
"php": ">= 8.0",
"dibi/dibi": "^5.0"
}
}
57 changes: 57 additions & 0 deletions dbal/dibi/v5.0/run-employees.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

use Dibi\Connection;

require_once __DIR__ . '/../../bootstrap.php';

Bootstrap::php('Dibi (~5.0)', '>=', '8.0.0');
Bootstrap::init();
Bootstrap::check(__DIR__);

$config = Bootstrap::$config['db'];
$connection = new Connection([
'driver' => 'mysqli',
'host' => 'localhost',
'database' => $config['dbname'],
'username' => $config['user'],
'password' => $config['password'],
]);

$startTime = -microtime(TRUE);
ob_start();

$employees = $connection->query('
SELECT emp_no, first_name, last_name
FROM employees
LIMIT %i', Bootstrap::$config['limit']
);

foreach ($employees as $employee) {
echo "{$employee->first_name} {$employee->last_name} ({$employee->emp_no})\n";

echo "Salaries:\n";
$salaries = $connection->query('
SELECT salary
FROM salaries
WHERE emp_no = %i', $employee->emp_no
);
foreach ($salaries as $salary) {
echo $salary->salary, "\n";
}

echo "Departments:\n";
$departments = $connection->query('
SELECT d.dept_name
FROM dept_emp de
JOIN departments d ON d.dept_no = de.dept_no
WHERE de.emp_no = %i', $employee->emp_no
);
foreach ($departments as $department) {
echo $department->dept_name, "\n";
}
}

ob_end_clean();
$endTime = microtime(TRUE);

Bootstrap::result('Dibi', '~5.0', $startTime, $endTime);
6 changes: 6 additions & 0 deletions dbal/nextras-dbal/v3.0/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"require": {
"php": ">= 7.2",
"nextras/dbal": "^3.0"
}
}
Loading