本文整理汇总了PHP中Cake\Datasource\ConnectionManager::drop方法的典型用法代码示例。如果您正苦于以下问题:PHP ConnectionManager::drop方法的具体用法?PHP ConnectionManager::drop怎么用?PHP ConnectionManager::drop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Datasource\ConnectionManager
的用法示例。
在下文中一共展示了ConnectionManager::drop方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDownAfterClass
/**
* Purge ConnectionManager configs.
*
* @return void
*/
public static function tearDownAfterClass()
{
foreach (self::$datasources as $ds => $configs) {
\Cake\Datasource\ConnectionManager::drop($ds);
}
\Cake\Utility\Security::salt('');
}
示例2: testJunctionConnection
/**
* Tests the junction passes the source connection name on.
*
* @return void
*/
public function testJunctionConnection()
{
$mock = $this->getMockBuilder('Cake\\Database\\Connection')->setMethods(['driver'])->setConstructorArgs(['name' => 'other_source'])->getMock();
ConnectionManager::config('other_source', $mock);
$this->article->connection(ConnectionManager::get('other_source'));
$assoc = new BelongsToMany('Test', ['sourceTable' => $this->article, 'targetTable' => $this->tag]);
$junction = $assoc->junction();
$this->assertSame($mock, $junction->connection());
ConnectionManager::drop('other_source');
}
示例3: tearDown
public function tearDown()
{
ConnectionManager::drop('twitter');
StreamWrapper::restoreWrapper('https');
}
示例4: testDrop
/**
* Tests that a connection configuration can be deleted in runtime
*
* @return void
*/
public function testDrop()
{
ConnectionManager::config('test_variant', ['className' => __NAMESPACE__ . '\\FakeConnection', 'database' => ':memory:']);
$result = ConnectionManager::configured();
$this->assertContains('test_variant', $result);
$this->assertTrue(ConnectionManager::drop('test_variant'));
$result = ConnectionManager::configured();
$this->assertNotContains('test_variant', $result);
$this->assertFalse(ConnectionManager::drop('probably_does_not_exist'), 'Should return false on failure.');
}
示例5: putenv
<?php
/**
* Test runner bootstrap.
*
* Add additional configuration/setup your application needs when running
* unit tests in this file.
*/
use Cake\Datasource\ConnectionManager;
require 'test-app/config/bootstrap.php';
if (!getenv('db_dsn')) {
putenv('db_dsn=sqlite:///:memory:');
}
ConnectionManager::drop('test');
ConnectionManager::config('test', ['url' => getenv('db_dsn')]);
示例6: getConn
/**
* Generates a new connection to DB.
*
* @return \Cake\Database\Connection|bool A connection object, or false on
* failure. On failure error messages are automatically set
*/
public function getConn()
{
if (!$this->config('connection.className')) {
$this->error(__d('installer', 'Database engine cannot be empty.'));
return false;
}
try {
ConnectionManager::drop('installation');
ConnectionManager::config('installation', $this->config('connection'));
$conn = ConnectionManager::get('installation');
$conn->connect();
return $conn;
} catch (\Exception $ex) {
$this->error(__d('installer', 'Unable to connect to database, please check your information. Details: {0}', '<p>' . $ex->getMessage() . '</p>'));
return false;
}
}
示例7: _dropTables
/**
* Removes all tables in current installation DB.
*
* @return void
*/
protected function _dropTables()
{
// drop all tables
ConnectionManager::drop('installation');
ConnectionManager::config('installation', $this->_getConn());
$db = ConnectionManager::get('installation');
$db->connect();
$tables = $db->schemaCollection()->listTables();
foreach ($tables as $table) {
$Table = TableRegistry::get($table, ['connection' => $db]);
$schema = $Table->schema();
$sql = $schema->dropSql($db);
foreach ($sql as $stmt) {
$db->execute($stmt)->closeCursor();
}
}
unset($db);
ConnectionManager::drop('installation');
}
示例8: tearDown
public function tearDown()
{
ConnectionManager::drop('twitter');
}