本文整理汇总了PHP中Nette\Database\Connection::getDsn方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::getDsn方法的具体用法?PHP Connection::getDsn怎么用?PHP Connection::getDsn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Database\Connection
的用法示例。
在下文中一共展示了Connection::getDsn方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* 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();
}
}
示例2: setConnection
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;
}
}
示例3: __construct
/**
* 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();
}
}
示例4: __construct
/**
* 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];
}
示例5: __construct
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;
}
示例6: __testbench_ndb_connectToDatabase
/** @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();
}
示例7: __construct
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()));
}
示例8: getDsnKey
/** @return string */
private function getDsnKey()
{
return sha1($this->connection->getDsn());
}
示例9: setConnection
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');
}
}