<?php use Nette\Caching\Storages\FileStorage; use Nette\Database\Connection; use Nette\Database\Context; use Nette\Database\Reflection\DiscoveredReflection; use Nette\Framework; require_once __DIR__ . '/../../bootstrap.php'; Bootstrap::init(); Bootstrap::check(__DIR__); $connection = new Connection(Bootstrap::$config['db']['driver'] . ':dbname=' . Bootstrap::$config['db']['dbname'], Bootstrap::$config['db']['user'], Bootstrap::$config['db']['password']); $cacheStorage = Bootstrap::$config['cache'] ? new FileStorage(__DIR__ . '/temp') : NULL; $dao = new Context($connection, new DiscoveredReflection($connection, $cacheStorage), $cacheStorage); $startTime = -microtime(TRUE); ob_start(); foreach ($dao->table('employees')->limit(Bootstrap::$config['limit']) as $employe) { echo "{$employe->first_name} {$employe->last_name} ({$employe->emp_no})\n"; echo "Salaries:\n"; foreach ($employe->related('salaries') as $salary) { echo $salary->salary, "\n"; } echo "Departments:\n"; foreach ($employe->related('dept_emp') as $department) { echo $department->dept->dept_name, "\n"; } } ob_end_clean(); $endTime = microtime(TRUE); Bootstrap::result('NetteDatabase', '~2.1.0', $startTime, $endTime);
use Nette\Caching\Storages\FileStorage; use Nette\Database\Connection; use Nette\Database\Context; use Nette\Database\Conventions\DiscoveredConventions; use Nette\Database\Structure; require_once __DIR__ . '/../../bootstrap.php'; Bootstrap::init(); Bootstrap::check(__DIR__); $cacheStorage = Bootstrap::$config['cache'] ? new FileStorage(__DIR__ . '/temp') : NULL; $connection = new Connection(Bootstrap::$config['db']['driver'] . ':dbname=' . Bootstrap::$config['db']['dbname'], Bootstrap::$config['db']['user'], Bootstrap::$config['db']['password']); $structure = new Structure($connection, $cacheStorage); $conventions = new DiscoveredConventions($structure); $context = new Context($connection, $structure, $conventions, $cacheStorage); $startTime = -microtime(TRUE); ob_start(); $employees = new EmployeeRepository($context); foreach ($employees->findAll()->limit(Bootstrap::$config['limit']) as $employee) { echo $employee->getFirstName(), ' ', $employee->getLastName(), ' (', $employee->getEmpNo(), ")\n"; echo 'Salaries:', "\n"; foreach ($employee->getSalaries() as $salary) { echo $salary->getSalary(), "\n"; } echo 'Departments:', "\n"; foreach ($employee->getDepartments() as $department) { echo $department->getName(), "\n"; } } ob_end_clean(); $endTime = microtime(TRUE); Bootstrap::result('YetORM', '~8.0', $startTime, $endTime);
use Model\EmployeesRepository; use Model\SalariesMapper; use Model\SalariesRepository; use Nette\Caching\Storages\FileStorage; use Nextras\Dbal\Connection; use Nextras\Orm\Model\SimpleModelFactory; require_once __DIR__ . '/../../bootstrap.php'; Bootstrap::init(); Bootstrap::check(__DIR__); $cacheStorage = Bootstrap::$config['cache'] ? new FileStorage(__DIR__ . '/temp') : NULL; $connection = new Connection(['driver' => Bootstrap::$config['db']['driver'] . 'i', 'username' => Bootstrap::$config['db']['user'], 'password' => Bootstrap::$config['db']['password'], 'dbname' => Bootstrap::$config['db']['dbname']]); $staticLoader = new SimpleModelFactory($cacheStorage, ['employees' => new EmployeesRepository(new EmployeesMapper($connection, $cacheStorage)), 'salarieys' => new SalariesRepository(new SalariesMapper($connection, $cacheStorage)), 'departments' => new DepartmentsRepository(new DepartmentsMapper($connection, $cacheStorage))]); $startTime = -microtime(TRUE); ob_start(); $model = $staticLoader->create(); $employees = $model->employees->findOverview(Bootstrap::$config['limit']); foreach ($employees as $employee) { echo "{$employee->firstName} {$employee->lastName} ({$employee->id})\n"; echo "Salaries:\n"; foreach ($employee->salaries as $salary) { echo $salary->salary, "\n"; } echo "Departments:\n"; foreach ($employee->departments as $department) { echo $department->name, "\n"; } } ob_end_clean(); $endTime = microtime(TRUE); Bootstrap::result('Nextras\\Orm', '~1.0', $startTime, $endTime);
require_once __DIR__ . '/../../bootstrap.php'; Bootstrap::init(); Bootstrap::check(__DIR__); $cache = Bootstrap::$config['cache'] ? new FilesystemCache(__DIR__ . '/temp') : NULL; $config = Setup::createAnnotationMetadataConfiguration([__DIR__ . '/model/entities'], TRUE, __DIR__ . '/model/entities/proxies', $cache, FALSE); $config->setProxyNamespace('Model\\Entities\\Proxies'); $config->setAutoGenerateProxyClasses(TRUE); // we need __toString on DateTime, since UoW converts composite primary keys to string // (who the hell invented composite PKs :P) Type::overrideType(Type::DATE, 'Model\\Types\\DateType'); Type::overrideType(Type::DATETIME, 'Model\\Types\\DateTimeType'); $em = EntityManager::create(['driver' => Bootstrap::$config['db']['driverpdo'], 'user' => Bootstrap::$config['db']['user'], 'password' => Bootstrap::$config['db']['password'], 'dbname' => Bootstrap::$config['db']['dbname']], $config); $startTime = -microtime(TRUE); ob_start(); $qb = $em->createQueryBuilder()->from('Model\\Entities\\Employee', 'e')->select('e')->innerJoin('e.salaries', 's')->addSelect('s')->innerJoin('e.affiliatedDepartments', 'd')->addSelect('d')->innerJoin('d.department', 'dd')->addSelect('dd')->setMaxResults(Bootstrap::$config['limit'])->getQuery(); $paginator = new Paginator($qb); foreach ($paginator->getIterator() as $employee) { echo $employee->getFirstName(), ' ', $employee->getLastName(), ' (', $employee->getId(), ")\n"; echo "Salaries:\n"; foreach ($employee->getSalaries() as $salary) { echo $salary->getAmount() . "\n"; } echo "Departments:\n"; foreach ($employee->getAffiliatedDepartments() as $department) { echo $department->getDepartment()->getName() . "\n"; } } ob_end_clean(); $endTime = microtime(TRUE); Bootstrap::result('Doctrine2', '~2.4.0', $startTime, $endTime);
<?php use LeanMapper\Connection; use LeanMapper\DefaultEntityFactory; use Model\Mapper; use Model\Repository\EmployeesRepository; require_once __DIR__ . '/../../bootstrap.php'; Bootstrap::init(); Bootstrap::check(__DIR__); $connection = new Connection(array('username' => Bootstrap::$config['db']['user'], 'password' => Bootstrap::$config['db']['password'], 'database' => Bootstrap::$config['db']['dbname'])); $startTime = -microtime(TRUE); ob_start(); $entityFactory = new DefaultEntityFactory(); $mapper = new Mapper(); $employeesRepository = new EmployeesRepository($connection, $mapper, $entityFactory); foreach ($employeesRepository->findAll(Bootstrap::$config['limit']) as $employee) { echo "{$employee->firstName} {$employee->lastName} ({$employee->empNo})\n"; echo "Salaries:\n"; foreach ($employee->salaries as $salary) { echo $salary->salary, "\n"; } echo "Departments:\n"; foreach ($employee->departments as $department) { echo $department->deptName, "\n"; } } ob_end_clean(); $endTime = microtime(TRUE); Bootstrap::result('LeanMapper', '~2.0', $startTime, $endTime);
use Nette\Caching\Storages\FileStorage; use Nette\Database\Connection; use Nette\Database\Context; use Nette\Database\Conventions\DiscoveredConventions; use Nette\Database\Structure; require_once __DIR__ . '/../../bootstrap.php'; Bootstrap::init(); Bootstrap::check(__DIR__); $cacheStorage = Bootstrap::$config['cache'] ? new FileStorage(__DIR__ . '/temp') : NULL; $connection = new Connection(Bootstrap::$config['db']['driver'] . ':dbname=' . Bootstrap::$config['db']['dbname'], Bootstrap::$config['db']['user'], Bootstrap::$config['db']['password']); $structure = new Structure($connection, $cacheStorage); $conventions = new DiscoveredConventions($structure); $context = new Context($connection, $structure, $conventions, $cacheStorage); $startTime = -microtime(TRUE); ob_start(); foreach ($context->table('employees')->limit(Bootstrap::$config['limit']) as $employe) { echo "{$employe->first_name} {$employe->last_name} ({$employe->emp_no})\n"; echo "Salaries:\n"; foreach ($employe->related('salaries') as $salary) { echo $salary->salary, "\n"; } echo "Departments:\n"; foreach ($employe->related('dept_emp') as $department) { echo $department->dept->dept_name, "\n"; } } ob_end_clean(); $endTime = microtime(TRUE); Bootstrap::result('NetteDatabase', 'dev-master', $startTime, $endTime);
<?php use Model\NotORMStructure; require_once __DIR__ . '/../../bootstrap.php'; Bootstrap::init(); Bootstrap::check(__DIR__); $connection = new PDO(Bootstrap::$config['db']['driver'] . ':dbname=' . Bootstrap::$config['db']['dbname'], Bootstrap::$config['db']['user'], Bootstrap::$config['db']['password']); $cache = Bootstrap::$config['cache'] ? new NotORM_Cache_File(__DIR__ . '/temp/notorm') : NULL; $notorm = new NotORM($connection, new NotORMStructure(), $cache); $startTime = -microtime(TRUE); ob_start(); foreach ($notorm->employees()->limit(Bootstrap::$config['limit']) as $employee) { echo "{$employee['first_name']} {$employee['last_name']} ({$employee['emp_no']})\n"; echo "Salaries:\n"; foreach ($employee->salaries() as $salary) { echo $salary['salary'], "\n"; } echo "Departments:\n"; foreach ($employee->dept_emp() as $relationship) { echo $relationship->departments['dept_name'], "\n"; } } ob_end_clean(); $endTime = microtime(TRUE); Bootstrap::result('NotORM', 'dev-master', $startTime, $endTime);