本文整理汇总了PHP中Doctrine\DBAL\Connection::getConfiguration方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::getConfiguration方法的具体用法?PHP Connection::getConfiguration怎么用?PHP Connection::getConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Connection
的用法示例。
在下文中一共展示了Connection::getConfiguration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: singleImport
private function singleImport($config, OutputInterface &$output, $entity_key = null)
{
$this->connection = $this->connectionFactory->createConnection($config['database']);
$this->connection->getConfiguration()->getSQLLogger(null);
if ($entity_key) {
if (!isset($config['maps'][$entity_key])) {
throw new \Exception("Entity alias not found: " . $entity_key);
}
$map = $config['maps'][$entity_key];
if (!$this->container->has($map['old_data']['service_id'])) {
throw new \Exception("Service not exists: " . $map['old_data']['service_id']);
}
$result = $this->importEntity($map);
$output->writeln("<info>Total " . count($result) . " {$entity_key} imported </info>");
} else {
foreach ((array) $config['maps'] as $key => $map) {
if (!$this->container->has($map['old_data']['service_id'])) {
throw new \Exception("Service not exists: " . $map['old_data']['service_id']);
}
$offset = 0;
do {
$result = $this->importEntity($map);
$output->writeln("<info>Total " . count($result) . " {$key} imported </info>");
if (!$result) {
break;
}
$offset++;
$this->setOffset($offset);
} while (true);
}
}
$this->connection->close();
}
示例2: setUp
/**
* Initializes the database (once).
*
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\Tools\ToolsException
*/
protected function setUp()
{
if (null === static::$_conn) {
$dbPath = __DIR__ . '/../../../db.sqlite';
if (file_exists($dbPath)) {
unlink($dbPath);
}
$params = ['driver' => 'pdo_sqlite', 'path' => $dbPath];
static::$_conn = DriverManager::getConnection($params);
static::$_conn->getConfiguration()->setSQLLogger(null);
}
if (null === static::$_em) {
$paths = [__DIR__ . '/../../../../../src/Ekyna/Commerce/Bridge/Doctrine/ORM/Resources/mapping'];
$isDevMode = true;
$config = Setup::createXMLMetadataConfiguration($paths, $isDevMode);
$em = EntityManager::create(static::$_conn, $config);
$classes = [];
foreach (static::$_classes as $class) {
array_push($classes, $em->getClassMetadata($class));
}
$schemaTool = new SchemaTool($em);
$schemaTool->dropSchema($classes);
$schemaTool->createSchema($classes);
// Load fixtures
$loader = new Loader();
$loader->loadFromDirectory(__DIR__ . '/../../../../../src/Ekyna/Commerce/Bridge/Doctrine/Fixtures');
$purger = new ORMPurger();
$executor = new ORMExecutor($em, $purger);
$executor->execute($loader->getFixtures());
static::$_em = $em;
}
}
示例3: setConnection
public function setConnection(Connection $conn)
{
$this->conn = $conn;
if ($this->debug) {
$this->logger = new DebugStack();
$this->conn->getConfiguration()->setSQLLogger($this->logger);
}
}
示例4: runQuery
/**
* @param $sql
* @return \Doctrine\DBAL\Driver\Statement
* @throws \Doctrine\DBAL\DBALException
*/
public static function runQuery($sql)
{
if (null === static::$dblaConnInstance) {
static::$dblaConnInstance = DriverManager::getConnection(static::getParamsConnection(), new Configuration());
static::$dblaConnInstance->getConfiguration()->setSQLLogger(self::logger());
}
return static::$dblaConnInstance->query($sql);
}
示例5: setResultCache
/**
* Set a caching method.
*
* It will not override an already set result cache
*
* @param Doctrine\Common\Cache\Cache a Cache interface
*/
public function setResultCache(Cache $cache)
{
$config = $this->conn->getConfiguration();
$this->hasResultCache = null != $config->getResultCacheImpl();
if (!$this->hasResultCache) {
$config->setResultCacheImpl($cache);
$this->hasResultCache = true;
}
}
示例6: setUp
protected function setUp()
{
if (!isset(self::$_sharedConn)) {
self::$_sharedConn = TestUtil::getConnection();
}
$this->_conn = self::$_sharedConn;
$this->_sqlLoggerStack = new \Doctrine\DBAL\Logging\DebugStack();
$this->_conn->getConfiguration()->setSQLLogger($this->_sqlLoggerStack);
}
示例7: setUp
public function setUp()
{
if (!isset(self::$_sharedConn)) {
$params = array('driverClass' => 'Crate\\DBAL\\Driver\\PDOCrate\\Driver', 'host' => 'localhost', 'port' => 4200);
self::$_sharedConn = \Doctrine\DBAL\DriverManager::getConnection($params);
}
$this->_conn = self::$_sharedConn;
$this->_sqlLoggerStack = new \Doctrine\DBAL\Logging\DebugStack();
$this->_conn->getConfiguration()->setSQLLogger($this->_sqlLoggerStack);
}
示例8: setConnection
/**
* @param \Doctrine\DBAL\Connection $connection
* @throws \Nette\InvalidStateException
*/
public function setConnection(Doctrine\DBAL\Connection $connection)
{
if ($this->connection !== NULL) {
throw new Nette\InvalidStateException("Doctrine Panel is already bound to connection.");
}
if (($logger = $connection->getConfiguration()->getSQLLogger()) instanceof Doctrine\DBAL\Logging\LoggerChain) {
$logger->addLogger($this);
} else {
$connection->getConfiguration()->setSQLLogger($this);
}
$this->connection = $connection;
}
示例9: _getConnection
protected function _getConnection()
{
if (!isset(self::$_conn)) {
self::$_conn = DriverManager::getConnection($this->_getDbParams(), new Configuration());
self::$_conn->getEventManager()->addEventSubscriber(new ORMSchemaEventSubscriber());
Configurator::configure(self::$_conn->getConfiguration());
if (!Type::hasType('tsvector')) {
Type::addType('tsvector', 'Doctrine\\DBAL\\Types\\TextType');
}
$platform = self::$_conn->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('tsvector', 'tsvector');
}
return self::$_conn;
}
示例10: _getConnection
protected function _getConnection()
{
if (!isset(self::$_conn)) {
$dbParams = array('driver' => $GLOBALS['db_type'], 'user' => $GLOBALS['db_username'], 'password' => $GLOBALS['db_password'], 'host' => $GLOBALS['db_host'], 'dbname' => $GLOBALS['db_name'], 'port' => $GLOBALS['db_port']);
self::$_conn = DriverManager::getConnection($dbParams, new Configuration());
self::$_conn->getEventManager()->addEventSubscriber(new ORMSchemaEventSubscriber());
Configurator::configure(self::$_conn->getConfiguration());
if (!Type::hasType('tsvector')) {
Type::addType('tsvector', 'Doctrine\\DBAL\\Types\\TextType');
}
$platform = self::$_conn->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('tsvector', 'tsvector');
}
return self::$_conn;
}
示例11: getDiff
/**
* @param Schema $targetSchema
* @param \Doctrine\DBAL\Connection $connection
* @return \Doctrine\DBAL\Schema\SchemaDiff
* @throws DBALException
*/
protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection)
{
// adjust varchar columns with a length higher then getVarcharMaxLength to clob
foreach ($targetSchema->getTables() as $table) {
foreach ($table->getColumns() as $column) {
if ($column->getType() instanceof StringType) {
if ($column->getLength() > $connection->getDatabasePlatform()->getVarcharMaxLength()) {
$column->setType(Type::getType('text'));
$column->setLength(null);
}
}
}
}
$filterExpression = $this->getFilterExpression();
$this->connection->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression);
$sourceSchema = $connection->getSchemaManager()->createSchema();
// remove tables we don't know about
/** @var $table \Doctrine\DBAL\Schema\Table */
foreach ($sourceSchema->getTables() as $table) {
if (!$targetSchema->hasTable($table->getName())) {
$sourceSchema->dropTable($table->getName());
}
}
// remove sequences we don't know about
foreach ($sourceSchema->getSequences() as $table) {
if (!$targetSchema->hasSequence($table->getName())) {
$sourceSchema->dropSequence($table->getName());
}
}
$comparator = new Comparator();
return $comparator->compare($sourceSchema, $targetSchema);
}
示例12: __construct
/**
* Initializes a new <tt>StandardEntityPersister</tt> that uses the given EntityManager
* and persists instances of the class described by the given class metadata descriptor.
*
* @param EntityManager $em
* @param ClassMetadata $class
*/
public function __construct(EntityManager $em, ClassMetadata $class)
{
$this->_em = $em;
$this->_class = $class;
$this->_conn = $em->getConnection();
$this->_sqlLogger = $this->_conn->getConfiguration()->getSqlLogger();
$this->_platform = $this->_conn->getDatabasePlatform();
}
示例13: enableLogging
public function enableLogging()
{
if ($this->connection === NULL) {
throw new Kdyby\Doctrine\InvalidStateException("Doctrine Panel is not bound to connection.");
}
$config = $this->connection->getConfiguration();
$logger = $config->getSQLLogger();
if ($logger instanceof Doctrine\DBAL\Logging\LoggerChain) {
$logger->addLogger($this);
} else {
$config->setSQLLogger($this);
}
}
示例14: execute
/**
* Executes the statement with the currently bound parameters.
*
* @param array|null $params
*
* @return boolean TRUE on success, FALSE on failure.
*
* @throws \Doctrine\DBAL\DBALException
*/
public function execute($params = null)
{
if (is_array($params)) {
$this->params = $params;
}
$logger = $this->conn->getConfiguration()->getSQLLogger();
if ($logger) {
$logger->startQuery($this->sql, $this->params, $this->types);
}
try {
$stmt = $this->stmt->execute($params);
} catch (\Exception $ex) {
throw DBALException::driverExceptionDuringQuery($ex, $this->sql, $this->conn->resolveParams($this->params, $this->types));
}
if ($logger) {
$logger->stopQuery();
}
$this->params = array();
$this->types = array();
return $stmt;
}
示例15: getDiff
protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection)
{
$filterExpression = $this->getFilterExpression();
$this->connection->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression);
$sourceSchema = $connection->getSchemaManager()->createSchema();
// remove tables we don't know about
/** @var $table \Doctrine\DBAL\Schema\Table */
foreach ($sourceSchema->getTables() as $table) {
if (!$targetSchema->hasTable($table->getName())) {
$sourceSchema->dropTable($table->getName());
}
}
// remove sequences we don't know about
foreach ($sourceSchema->getSequences() as $table) {
if (!$targetSchema->hasSequence($table->getName())) {
$sourceSchema->dropSequence($table->getName());
}
}
$comparator = new Comparator();
return $comparator->compare($sourceSchema, $targetSchema);
}