/** * Create autodiscovery structure. */ public function __construct(Nette\Database\Connection $connection, Nette\Caching\IStorage $cacheStorage = NULL) { $this->connection = $connection; if ($cacheStorage) { $this->cache = new Nette\Caching\Cache($cacheStorage, 'Nette.Database.' . md5($connection->getDsn())); $this->structure = $this->loadedStructure = $this->cache->load('structure') ?: array(); } }
public function setConnection(Nette\Database\Connection $connection) { $this->connection = $connection; if ($this->cacheStorage) { $this->cache = new Nette\Caching\Cache($this->cacheStorage, 'Nette.Database.' . md5($connection->getDsn())); $this->structure = $this->cache->load('structure') ?: $this->structure; } }
/** * Create autodiscovery structure. */ public function __construct(Nette\Database\Connection $connection, Nette\Caching\IStorage $cacheStorage = NULL) { trigger_error(__CLASS__ . '() is deprecated; use Nette\\Database\\Conventions\\DiscoveredConventions instead.', E_USER_DEPRECATED); $this->connection = $connection; if ($cacheStorage) { $this->cache = new Nette\Caching\Cache($cacheStorage, 'Nette.Database.' . md5($connection->getDsn())); $this->structure = $this->loadedStructure = $this->cache->load('structure') ?: array(); } }
/** * Creates filtered table representation. * @param Nette\Database\Connection * @param string database table name */ public function __construct(Nette\Database\Connection $connection, $table, Nette\Database\IReflection $reflection, Nette\Caching\IStorage $cacheStorage = NULL) { $this->name = $table; $this->connection = $connection; $this->reflection = $reflection; $this->cache = $cacheStorage ? new Nette\Caching\Cache($cacheStorage, 'Nette.Database.' . md5($connection->getDsn())) : NULL; $this->primary = $reflection->getPrimary($table); $this->sqlBuilder = new SqlBuilder($table, $connection, $reflection); $this->refCache =& $this->getRefTable($refPath)->globalRefCache[$refPath]; }
public function __construct($sqlDir, $sqlExt, $dbUpdateTable, $definerUser, $definerHost, Database\Connection $dbConnection, Database\IStructure $structure) { $this->sqlDir = $sqlDir . DIRECTORY_SEPARATOR; $this->sqlExt = $sqlExt; $this->dbUpdateTable = $dbUpdateTable; $this->db = new Database\Context($dbConnection, $structure); $this->dbName = $this->getDbNameFromDsn($dbConnection->getDsn()); $this->definerUser = $definerUser; $this->definerHost = $definerHost; }
/** @internal */ private function __testbench_ndb_connectToDatabase(Connection $db, $databaseName = NULL) { //connect to an existing database other than $this->_databaseName $container = $this->__testbench_ndb_getContainer(); if ($databaseName === NULL) { $config = $container->parameters['testbench']; if (isset($config['dbname'])) { $databaseName = $config['dbname']; } elseif ($db->getSupplementalDriver() instanceof PgSqlDriver) { $databaseName = 'postgres'; } else { throw new \LogicException('You should setup existing database name using testbench:dbname option.'); } } $dsn = preg_replace('~dbname=[a-z0-9_-]+~i', "dbname={$databaseName}", $db->getDsn()); $dbr = $db->getReflection(); //:-( $params = $dbr->getProperty('params'); $params->setAccessible(TRUE); $params = $params->getValue($db); $options = $dbr->getProperty('options'); $options->setAccessible(TRUE); $options = $options->getValue($db); $db->disconnect(); $db->__construct($dsn, $params[1], $params[2], $options); $db->connect(); }
public function __construct(Connection $connection, Nette\Caching\IStorage $cacheStorage) { $this->connection = $connection; $this->cache = new Nette\Caching\Cache($cacheStorage, 'Nette.Database.Structure.' . md5($this->connection->getDsn())); }
/** @return string */ private function getDsnKey() { return sha1($this->connection->getDsn()); }
function setConnection(Nette\Database\Connection $connection) { $this->connection = $connection; if ($this->cacheStorage) { $this->cache = new Nette\Caching\Cache($this->cacheStorage, 'Nette.Database.Discovery/' . $connection->getDsn()); $this->structure = $this->cache->load('structure'); } }