Skip to content

Instantly share code, notes, and snippets.

@licvido
Last active January 15, 2016 17:44
Show Gist options
  • Save licvido/4d6e78967f47b37a996a to your computer and use it in GitHub Desktop.
Save licvido/4d6e78967f47b37a996a to your computer and use it in GitHub Desktop.
NETTE: Database connection sample
<?php
require 'nette.phar';
Tracy\Debugger::enable();
$dsn = "mysql:host=localhost;dbname=database";
$user = "root";
$password = "***";
$connection = new Nette\Database\Connection($dsn, $user, $password);
$cacheStorage = new Nette\Caching\Storages\MemoryStorage;
$structure = new Nette\Database\Structure($connection, $cacheStorage);
$conventions = new Nette\Database\Conventions\DiscoveredConventions($structure);
$context = new Nette\Database\Context($connection, $structure, $conventions, $cacheStorage);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment